Skip to content
Advertisement

How to copy all records and add some changes in the same table in OracleDB

I would like to copy all records into the same table with some changes. Is someone tell me a good way?

I tried to this. but Not Ended error happen. How can I fixt it?

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 command not properly ended” 00933. 00000 – “SQL command not properly ended” *Cause:
*Action:

Advertisement

Answer

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;
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement