通过合并两个表并创建一个新表 [英] Create a new table from merging two tables with union

查看:80
本文介绍了通过合并两个表并创建一个新表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个具有相同列的表.

I have two tables with the same columns.

我可以将它们与UNION

select * from  table1
union
select * from table2;

如何创建具有与该查询相同的内容和列的新表?

How do I create a new table with the same contents and columns as that query?

推荐答案

您可以使用 CREATE TABLE ... SELECT 语句.

CREATE TABLE new_table
  SELECT * FROM table1
    UNION
  SELECT * FROM table2;

这篇关于通过合并两个表并创建一个新表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆