在SQL中,有两种对原表进行数据复制,有两种方式,insert into from 和 select into from 。
命令详解:
insert into from : insert into 新表名(列1,列2.......) select 列1,列2......from 源表名 where 限制条件 ;(该命令使用前提:目标表已经存在)
select into from :select 列1, 列2, ...... into 新表名(列1,列2.....) from 源表名;(该命令使用前提:目标表不存在)。
在DB2中,insert into from 可以正常使用,但是select into from 不能执行,因为DB2对select into from 做了限制,每次最大只能对一列插入一行数据。
因此,在DB2中要对表进行复制,可以使用
create table '新表名' like ’源表名‘;
insert into from ;