【问题标题】:How to copy all records and add some changes in the same table in OracleDB如何复制所有记录并在 Oracle DB 的同一张表中添加一些更改
【发布时间】:2020-10-09 06:19:03
【问题描述】:

我想将所有记录复制到同一个表中并进行一些更改。 有人告诉我一个好方法吗?

我试过了。但发生未结束错误。 我该如何解决?

CREATE TEMPORARY TABLE "TestScheme".tmp_history FROM history;
UPDATE tmp_history set
birthday  =  ADD_MONTHS(birthday,-24),
TRD_SEQ = replace('Stack','poo','pee')
INSERT INTO history SELECT * FROM  "TestScheme".tmp_history

ORA-00933:“SQL 命令未正确结束” 00933. 00000 - “SQL 命令未正确结束” *原因:
*行动:

【问题讨论】:

    标签: sql oracle oracle11g create-table


    【解决方案1】:
    create table tmp_history as
      select * from history
      where card_no = 'XXXX3';
    
    update tmp_history set
      birthday = add_months(birthday, -24),
      trd_seq = replace('Stack', 'poo', 'pee');
    
    insert into history 
      select * from tmp_history;
    

    【讨论】:

    • 唯一的原因是没有行包含值等于 XXXX3 的 CARD_NO。
    • 原表包含XXX3
    猜你喜欢
    • 2021-12-16
    • 2021-12-31
    • 2021-05-05
    • 2019-08-30
    • 1970-01-01
    • 2020-06-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多