简体   繁体   中英

how to insert data from one database to another database without any change in the target database?

I am having local database which has 13000 records and global database having 12500 records. now I need to insert the missing 500 records into global database. I used navicat data synchronization option but it does not compare the records and inserts the missed one.Please advice how to compare the total records in each database and inserts the missed records.

Assuming both the tables have same layout:

This query will fetch all records existing in local_table which are not in global_table

select * from local_table t1 left join global_table t2 on t1.primarykey = t2.primarykey where t2.primarykey is null

Now u simply have to insert records fetched from above query!!

Insert all the values from local database to global database. Find count of all the records after applying groupby on one cloumn. Delete all values with count=2. I am making an assumption that local database does not have any duplicates.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM