SQL:将查询结果保存到其他表的方法

一:目标表不存在

   sqlserver:select * into 目标表(新表) from 原表 where ...

  mysql:create table 目标表(新表) as select * from 原表 where ...

二:目标表已存在

  a. 保存全部

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

  b. 保存指定列

    insert into 目标表(列a, b, c) select 列a, b, c from 原表 where ...

三:跨数据库操作,把A数据库的atable表所查询的东西,插入到B 数据库的btable表中

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

星光不问赶路人,时光不负有心人。

原文地址:https://www.cnblogs.com/wq-code/p/10476631.html