create table select from 和 insert into table select from区别

create table select from 和 insert into table select from都是用来复制表,两者的主要区别为:

create table select from 要求目标表不存在,因为在插入时会自动创建。

insert into table select from 要求目标表存在,相当于复制插入。
备份表数据:

create table tmp_article_info as select * from article_info

还原表数据:

insert into tmp_article_info select * from article_info

只复制表结构:

 create table tmp_article_info as select * from article_info where 1=0

只复制表数据(如果两个表结构完全一样):

insert into tmp_article_info select * from article_info

只复制表数据(如果两个表结构不一样,或者部分复制):

insert into tmp_article_info (column1,column2…) select column1,column2 from article_info

腾讯云限时秒杀【点击购买】

搬瓦工,CN2高速线路,1GB带宽,电信联通优化KVM,延迟低,速度快,建站稳定,搬瓦工BandwagonHost VPS优惠码BWH26FXH3HIQ,支持<支付宝> 【点击购买】!

Vultr$3.5日本节点,512M内存/500G流量/1G带宽,电信联通优化,延迟低,速度快【点击购买】!

阿里云香港、新加坡VPS/1核/1G/25G SSD/1T流量/30M带宽/年付¥288【点击购买】

create table select from 和 insert into table select from区别

`微信`扫码 加好友

链接到文章: https://www.gkxyz.com/create-table-select-from-he-insert-into-table-select-fromqubie.html

推荐站点

  • Akamai(Linode)

    Deploy more with Linux virtual machines, global infrast […]

  • Vultr

    Vultr Global Cloud Hosting – Brilliantly Fast SSD […]

  • RAKsmart

    主机商介绍:RAKsmart是知名的美国服务器租用商,包括美国站群服务器、美国cn2服务器、香港服务器等热门产 […]

  • 腾讯云 – 产业智变 云启未来

    腾讯云为数百万的企业和开发者提供安全稳定的云计算服务,涵盖云服务器、云数据库、云存储、视频与CDN、域名注册等 […]

评论已关闭