Reputation: 1105
I have an oracle SQL table whose rows I'd like to duplicate, while incrementing the id for each row and change the value of 2 columns. So the pseudo code would go so something like this:
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
Can someone show how I would do this in Oracle SQL?
Upvotes: 1
Views: 1021
Reputation: 9211
insert into t(id, columnA, columnB)
select id + 1, 12, 13 from t;
Upvotes: 1