Oracle copies an SQL statement (test OK) for any table row, oraclesql
I tested it for a long time. There are many methods on the Internet, but they are all incorrect. The correct method is as follows:
declare cursor rowAll is select * from tb_news where 1=1; row1 tb_news%rowtype; i int; begin i := 0; for row1 in rowAll loop row1.id := fn_gen_getid('tb_news'); row1.addtime := sysdate; row1.starttime := sysdate; row1.adduserid := -100; insert into tb_news values row1; commit; end loop;end;
I did not expect this. However, I used dbms_output.put_line (sysdate) in the query window. I reported an error and crashed! By default7 # zbphp.com
SQL statement to copy a row of data to another table with the same structure
The SQL statement is tested.
Insert into sys_t_system backup select top 1 * from sys_t_system where
The first field not in (select top 149 first field from sys_t_system)
149 means that no more than 149 records are obtained.
1 indicates how many records are obtained.
For example, if you want to get 151st to 160
Insert into sys_t_system backup select top 10 * from sys_t_system where
The first field not in (select top 150 first field from sys_t_system)
An oracle SQL statement is taught. For example, table A has a data primary key A. copy the data and insert it into Table A. The primary key is changed to B.
Insert into A (pk, col1, col2 ...)
Select B as pk, col1, col2...
From
Where pk =;