insert into SONEDBA.FSTDAYSCHEDULE values((SELECT COALESCE(MAX(FSTDAYSCHEDULEKY), 0) + 1 FROM sonedba.FSTDAYSCHEDULE),1,2009,'NonBankDay',Date('2009-03-02'),'4','2009-03-02 11:31:27.203',null,'admin',1);
insert into SONEDBA.FSTDAYSCHEDULE values((SELECT COALESCE(MAX(FSTDAYSCHEDULEKY), 0) + 1 FROM sonedba.FSTDAYSCHEDULE),1,2009,'NonBusinessDay',Date('2009-03-02'),'1','2009-03-02 12:51:52.775',null,'admin',1);
*************************************************
在写Sql语句插入数据时,数据类型不匹配很容易出错:Character, Varchar等是需要加''的,如以上语句;注意Date, Timestamp类型。
*****************************************************************
Oracle数据类型改变函数:to_char()、to_date()、to_number()等;如果仅仅取年,月,日等,可以用to_char(sysdate, 'YYYY'),to_char('MM') ,to_char('DD')取得。只取年月日TRUNC(SYSDATE),取时分秒TO_CHAR(SYSDATE,'HH24:MI:SS')。
DB2数据类型改变函数:char()、varchar()、int()、date()、time()等;取得年,月,日等的写法:YEAR(current timestamp),MONTH(current timestamp),DAY(current timestamp),HOUR(current timestamp),MINUTE(current timestamp),SECOND(current timestamp),MICROSECOND(current timestamp),只取年月日可以用DATE(current timestamp),取时分秒TIME(current timestamp)。Char()是定长字符串(1-255),varchar()为非定长字符串(1-32672)日期,时间形态变为字符形态: char(current date),char(current time)将字符串转换成日期或时间形态:TIMESTAMP('2002-10-2012:00:00'),DATE('2002-10-20'),DATE('10/20/2002'),TIME('12:00:00')