select into 和insert into select

Posted 夏风微凉

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了select into 和insert into select相关的知识,希望对你有一定的参考价值。

select into:

  创建测试语句

create database MyDemoTest
go
use MyDemoTest
go
create table A
(
    a int primary key,
    b int,
)
go
insert into A values(1,1),
(2,2),
(3,3)

  执行核心语句:

select a,b into B from A

  执行结果:

  由这个结果我们可以知道,B表在插入的时候并不存在

 insert into select:

 

drop table B
create table B
(
    a int primary key,
    b int,
)
go
insert into B(a,b) select a,b from A

 

以上是关于select into 和insert into select的主要内容,如果未能解决你的问题,请参考以下文章

select into 和insert into select

select into from 和 insert into select

mysql中select into 和sql中的select into 对比

Oracle中insert into select和select into的区别

Oracle中insert into select和select into的区别

select into from 与 select into from opendatasource