select into from 和 insert into select 的区别和使用
2013-10-28 12:42
627 查看
select into from 和 insert into select都是用来复制表
两者的主要区别:
select into from 要求目标表不存在,因为在插入时会自动创建。insert into select from 要求目标表存在
INSERT INTO SELECT语句
语句形式:
Insert into Table2(field1,field2,...) select value1,value2,... from Table1注意地方:
(1)要求目标表Table2必须存在,并且字段field,field2...也必须存在(2)注意Table2的主键约束,如果Table2有主键而且不为空,则 field1, field2...中必须包括主键
(3)注意语法,不要加values,和插入一条数据的sql混了,不要写成:
Insert into Table2(field1,field2,...) values (select value1,value2,... from Table1)
(4)由于目标表Table2已经存在,所以我们除了插入源表Table1的字段外,还可以插入常量。
SELECT INTO FROM语句
语句形式
SELECT vale1, value2 into Table2 from Table1
说明
要求目标表Table2不存在,因为在插入时会自动创建表Table2,并将Table1中指定字段数据复制到Table2中 。参考资料: select into from 和 insert into select 的用法和区别 http://www.studyofnet.com/news/182.html
相关文章推荐
- Insert into select 和 select into from 区别
- insert into select和select into的使用和区别介绍
- select into from 和 insert into select 区别
- insert into select和select into from 区别
- select into from 和 insert into from 的区别
- insert into from和select from into的区别
- 数据库_MySQL_mysql中insert into select from的使用
- select into from 与 insert into select 区别
- INSERT INTO SELECT语句与SELECT INTO FROM语句的一些区别
- SELECT INTO FROM 和 INSERT INTO SELECT 的用法和区别
- insert into ... select 和 select ... into的使用和区别
- select into from 和 insert into select 的用法和区别
- select into from 和 insert into select 的用法和区别
- select into from 和 insert into select 的用法和区别
- select into from 和 insert into select 的用法和区别
- mysql中insert into select from的使用
- Insert into select 和 select into from 区别
- select into from 与 insert into select 区别鉴赏
- select into from 与 insert into select 区别鉴赏
- select into from 和 insert into select 的用法和区别