我想复制一个表中的一些数据,并且只更改一列。它看起来如下:
Before:
C1 C2 C3 .... // C1 C2 C3 are columns, C3 have same value
a1 b1 c
a2 b2 c
a3 b3 c
After:
C1 C2 C3 .... // for the copy, all columns are same except C3, all c and f are same value
a1 b1 c
a2 b2 c
a3 b3 c
...
a1 b1 f
a2 b2 f
a3 b3 f
有没有快速的方法在sql中执行此操作?谢谢!
答案 0 :(得分:2)
insert into your_table (C1, C2, C3)
select C1, C2, 'f'
from your_table