mysql把一張表的資料批量複製到另外一張表

2021-10-13 07:12:45 字數 940 閱讀 4228

1. 表結構完全一樣

insert into 表1 select * from 表2

2. 表結構不一樣(需要指定列名,並且要一一對應)

insert into 表1 (列名1,列名2,列名3) select 列1,列2,列3 from 表2

1. 表結構完全一樣

insert into 表1 select * from 表2 where not exists

(select * from 表1 where 列名1 = 表2.列名1)

2. 表結構不一樣(需要指定列名,並且要一一對應)

insert into 表1 (列名1,列名2,列名3) select 列名1,列名2,列名 from 表2 where not exists

(select * from 表1 where 列名1 = 表2.列名1)

例如:

insert into coupon_repository.`ekp_repo_merchant`(`name`,pic_url,external_id,

external_shop_id,`type`,external_cid,external_category,external_level,brand,website_url,keywords,description)

select tb_nick,logo_img_url,user_id,sid,shop_type,shop_cate,category,`level`,brand,website_url,

keywords,description from e_coupon.`ec_merchant` where not exists

(select * from coupon_repository.`ekp_repo_merchant` where `name` = e_coupon.`ec_merchant`.`tb_nick`)

MYSQL把一張表的資料批量複製到另外一張表

mysql資料庫快速將乙個表的資料備份到另乙個表中。如果有b表就刪除 drop table if exists b 根據a表結構建立b表 create table b like a 查詢a表資料插入b表 insert into b select from a create table 表1 like...

hbase禁用一張表和把禁用的一張表恢復狀態

首先需要先讓該錶為disable狀態,使用命令 disable 表名 然後才能drop這個表,使用命令 drop 表名 注意 如果直接drop表,會報錯 drop the named table.table must first be disabled 但是,如果禁用一張表之後發現不想刪除了,可以用...

將一張表的資料插入另外一張表

表cmb send sms create table cmb send sms send id bigint 20 not null auto increment comment 主鍵id phone no varchar 32 not null comment 手機號碼 status varcha...