已经有一个日期时间字段 ttime。
如何分别取出年、月、日存到3个新的字段?

解决方案 »

  1.   

    SQL> select sysdate from dual;SYSDATE
    --------------
    12-7月 -08SQL> select to_char(sysdate, 'yyyy'), to_char(sysdate, 'mm'), to_char(sysdate, '
    dd') from dual;TO_C TO TO
    ---- -- --
    2008 07 12SQL>
      

  2.   

    insert into tableName select to_char(ttime,'yyyy'),to_char(ttime,'MM'),to_char(ttime,'dd') from yourTable;
      

  3.   

    declare 
       year varchar(6);
       month varchar(6);
       day varchar(6);
    begin
       select to_char(ttime,'yyyy'),to_char(ttime,'mm'),to_char(ttime,'dd')
    into
      year,month,day;
    end;
    /
      

  4.   

     select to_char(sysdate, 'yyyy'), to_char(sysdate, 'mm'), to_char(sysdate, ' 
    dd') from dual; 
      

  5.   

    to_char(sysdate,'yyyy')
    to_char(sysdate, 'mm'), 
    to_char(sysdate, 'dd')
      

  6.   

    insert into newtableName select to_char(ttime,'yyyy'),to_char(ttime,'MM'),to_char(ttime,'dd') from oldtablename;