insert into table select * from table where primarykey=1
Run Code Online (Sandbox Code Playgroud)
我只想复制一行插入到同一个表中(即,我想复制表中的现有行)但我想这样做而不必列出"select"之后的所有列,因为这个表有列太多了.
但是当我这样做时,我得到错误:
密钥1的重复条目"xxx"
我可以通过创建另一个具有相同列的表作为我要复制的记录的临时容器来处理这个问题:
create table oldtable_temp like oldtable;
insert into oldtable_temp select * from oldtable where key=1;
update oldtable_tem set key=2;
insert into oldtable select * from oldtable where key=2;
Run Code Online (Sandbox Code Playgroud)
有没有更简单的方法来解决这个问题?