简体   繁体   English

从没有标识列的临时表插入表?

[英]Insert into table from a temp table without identity column ?

I need to insert into table with same column in temp table. 我需要在临时表的同一列中插入表。 without identity column of table which am inserting. 没有要插入的表的标识列。 Remaining columns of inserting table is contained in temp table. 插入表的其余列包含在临时表中。

You need to be able to generate primary key values on your own. 您需要能够自行生成主键值。 With IBM DB2, I am using sequences to get those values. 在IBM DB2中,我正在使用序列来获取这些值。 It would be good to know which RDBMS you are using. 最好知道您使用的是哪个RDBMS。

A statement matching your needs could look like that: 符合您需求的语句如下所示:

INSERT INTO MYSCHEMA.MYTABLE 
select (NEXTVAL FOR MYSCHEMA.ID_SEQUENCE) as ID, T.*
from MYSCHEMA.MYTEMPTABLE T

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM