SQL:将查询结果插入到另一个表的三种情况

来源:互联网 发布:禁止域用户安装软件 编辑:程序博客网 时间:2024/06/06 11:02

一:如果要插入目标表不存在:

select * into 目标表 from 表 where ...

二:如果要插入目标表已经存在:

insert into 目的表 select * from 表 where 条件

三:如果是跨数据库操作的话: 怎么把A数据库的atable表所查询的东西,全部插入到B 数据库的btable表中

select * into B.btable from A.atable where ...

0 0