sql 插入另一个表的查询结果


<!--同一个数据库-->
<!--目标表不存在 -->
select * into 目标表 from 查询表 where ...
select * into  abc from student 

<!-- 目标表存在  -->   
insert into 目标表 select * from 查询表 where ...
insert into student select * from abc

<!--跨数据库-->
<!--目标表不存在 -->
select * into 目标数据库..目标表 from 查询数据库..查询表 where ....
select * into 数据库A..student from  数据库B..student;

<!-- 目标表已经存在-->
insert into 目标数据库..目标表  select * from 查询数据库..查询表
insert into 数据库A..aaa select * from 数据库B..saver;
 

猜你喜欢

转载自blog.csdn.net/liufeifeinanfeng/article/details/82999532