我创建table1了a,b,c,d包含数据的列.
table2基本上是相同的,因为table1它有不同的列顺序+附加列,即a,e,d,b,c没有数据.
如何将数据复制table1到table2注释列a是一个id,我希望数字保持不变.
这是我已经尝试过的:
insert into table2 select (a,d,b,c) from table1
Run Code Online (Sandbox Code Playgroud)
这导致了 column "a" is of type bigint but expression is of type record
insert into table2 (a,d,b,c) values(select a,d,b,c from table1)
Run Code Online (Sandbox Code Playgroud)
也没用 syntax error at or near "select"
insert into table2 (a,e,d,b,c) values(select a,NULL,d,b,c from table1)
Run Code Online (Sandbox Code Playgroud)
得到了错误: INSERT has more target columns than expressions
Rob*_*rco 15
指定要插入的列名,但values在定义select时不要使用.
insert into table2(a,d,b,c) select a, d, b, c from table1
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10077 次 |
| 最近记录: |