修改语句怎么写,新手求教啊oraclesql

解决方案 »

  1.   

    假设表名为 t_table
    列名为 column_name
    想要将日期改为 9月1日
    update t_table
       set column_name = to_date(to_char(column_name, 'yyyy') || '-' || '09-01' ||
                                 to_char(column_name, ' hh24:mi:ss'),
                                 'yyyy-mm-dd hh24:mi:ss');
      

  2.   

    截取,连接两个动作。SQL> with t as (select '20130829123121' rq from dual)
      2  select rq,'20130830'||substr(rq,-6) newrq from t
      3  ;RQ             NEWRQ
    -------------- --------------------
    20130829123121 20130830123121
      

  3.   

    to NorthStar21
    如果年份也要修改呢?
      

  4.   

    假设表名为 t_table
    列名为 column_name
    想要将日期改为 2013年9月1日
    update t_table
       set column_name = to_date('2013' || '-' || '09-01' ||
                                 to_char(column_name, ' hh24:mi:ss'),
                                 'yyyy-mm-dd hh24:mi:ss');
      

  5.   


    SELECT to_char(SYSDATE,'YYYYMMDD'),to_char(SYSDATE,'HH24:MI:SS') FROM dual; 看完这个,你应该会了。