2013-01-21 21 views
1

我有一个Oracle SQL表,其行要重复,同时增加每行的id并更改2列的值。所以伪代码将如此类似:Oracle SQL - 表中的重复行和更新列

for each row r in TABLE t 
    new n = r 
    n.id = r.id+1 
    n.columnA = 12 
    n.columnB = 13 
    insert n into t 

有人可以显示我将如何在Oracle SQL中执行此操作吗?

回答

1
insert into t(id, columnA, columnB) 
select id + 1, 12, 13 from t; 
+0

这看起来很完美,谢谢你。 – jtyler