加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MsSql教程 > 正文

select into的用法

发布时间:2020-12-12 15:11:34 所属栏目:MsSql教程 来源:网络整理
导读:select into 的用法: select *?into?destTbl from srcTbl( 只能用于 sqlserver ) insert into destTbl(fld1,fld2) select fld1,5 from srcTbl( 两者通用 ) 以上两句都是将 srcTbl 的数据插入到 destTbl ,但两句又有区别的: 第一句( select into from )

select into的用法:

select *?into?destTbl from srcTbl(只能用于sqlserver)
insert into destTbl(fld1,fld2) select fld1,5 from srcTbl(
两者通用)

以上两句都是将 srcTbl 的数据插入到 destTbl,但两句又有区别的:

第一句(select into from)要求目标表(destTbl)不存在,因为在插入时会自动创建。

第二句(insert into select from)要求目标表(destTbl)存在,由于目标表已经存在,所以我们除了插入源表(srcTbl)的字段外,还可以插入常量,如例中的:5

例如:

insert into recu_a001(id,a001001,a001007,a001011,a001021,a001077,a001780) select id,a001780 from a001

这是往oracle中插入数据的。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读