温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

select into from与insert into select的区别有哪些

发布时间:2021-09-24 09:53:56 来源:亿速云 阅读:97 作者:iii 栏目:数据库

本篇内容主要讲解“select into from与insert into select的区别有哪些”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“select into from与insert into select的区别有哪些”吧!

步骤/方法

1、首先,我们来看一下insert into select语句,其语法形式为:Insert into Table2(field1,field2,...) select value1,value2,... from Table1。

select into from与insert into select的区别有哪些 

2、这里的要求就是Table2必须已经存在,如果不存在,系统则会提示对象无效。

select into from与insert into select的区别有哪些 

3、同时因为Table2已经存在,所以我们就可以任意的向Table2中加入符合列类型的内容,当然也包括常量,也许通过下面的图,你就会发现,在导入常量时候的不寻常现象了。

select into from与insert into select的区别有哪些 

4、接下来说一下select into from 语句,该语法形式为:SELECT vale1, value2 into Table2 from Table1。

select into from与insert into select的区别有哪些 

5、这里要求的是MyTable1不存在,因为在插入的时候,系统会自动创建MyTable1,如果之前MyTable1已经被创建,系统就会提示已经存在表。

select into from与insert into select的区别有哪些 

6、就是因为这个特性,就会给我们带来很多的方便,首先,我如果只想要MyTable2表中的ID列的话那我只需要将ID列select出来,然后加入到新表中即可。

select into from与insert into select的区别有哪些 

7、那如果我想要MyTable2中的Name列,那我也仅仅是需要把Name列select出来,然后添加到新表中即可。

select into from与insert into select的区别有哪些 

到此,相信大家对“select into from与insert into select的区别有哪些”有了更深的了解,不妨来实际操作一番吧!这里是亿速云网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI