简体   繁体   中英

How can i synchronize a temp table and a normal table?

i have a shop and the products are stored in a csv file. The csv file are imported by a cronjob in a temp table. my problem is to synchronize the temp table with the normal table (productive). some rows must be updated, added or deleted. I can't import the CSV file in the productive table because the intervall must be every 30 minutes.

Does anybody knows a program for this problem? For windows and mysql 5.0.x?

greetings!

You could just replace the original table with the temporary table:

DROP TABLE `ORIGINAL_TABLE`;
RENAME TABLE `TEMPORARY_TABLE` TO `ORIGINAL_TABLE`;

Or even safer...back up the original table first...

DROP TABLE IF EXISTS `BACKUP_TABLE`;
CREATE TABLE `BACKUP_TABLE` LIKE `ORIGINAL_TABLE`;
INSERT INTO `BACKUP_TABLE` SELECT * FROM `ORIGINAL_TABLE`;
DROP TABLE `ORIGINAL_TABLE`;
RENAME TABLE `TEMPORARY_TABLE` TO `ORIGINAL_TABLE`;

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