mysql 數據庫表遷移復制


1. 表結構相同的表,且在同一數據庫(如,table1,table2)

insert into table1 select * from table2  # 完全復制

insert into table1 select distinct * from table2 # 不復制重復紀錄

insert into table1 select top 5 * from table2  # 前五條紀錄

insert into table1(a,b,c) select a,b,c from table2 # 插入指定字段值


2. 不在同一數據庫中(如,db1 table1,db2 table2)

insert into db1.table1 select * from db2.table2  #完全復制

insert into db1.table1 select distinct * from db2.table2 # 不復制重復紀錄

insert into db1.table1 select top 5 * from db2.table2  # 前五條紀錄
insert into db1.table1(a,b,c) select a,b,c from db2.table2 # 插入指定字段值

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM