sean kim sean kim - 1 month ago 7
MySQL Question

What is a good way to erase the entire data and load the new data in a service table?

I am new in MySQL.

I receive full metadata every day.

However, I do not know which data is added, deleted and updated.

I use MySQL and the size of the data is about one million.

What is a good way to erase the entire data and load the new data in a service table?

I think about the following methods.

first option,

Run Delete and insert in a transaction.

second option,

RENAME TABLE foo TO foo_old, foo_new To foo

Please advise me how to deal with it.

Ben Ben
Answer

you can truncate the table and import your new data afterwards. You dont need to rename anything.

query truncate:
TRUNCATE TABLE {tableName};

cli import:
mysql -u {username} -p {database} < {importFile.sql}