FrozenHeart
FrozenHeart

Reputation: 20726

How to replace whole table

I need to create database that should represent currently available torrents on torrent tracker and update it completely every day or so, replacing previously saved data and erasing records about those torrents which were deleted from the site.

How can I do it? If I just collect new data in the temporary table and then try to do DROP TABLE and rename temporary table to the main table's name, I'll make other resources which also use this DB unable to do their work for some period of time. Or this is the best way to do it anyway and I should just do these operations in one transaction?

I'm going to use MySQL or PostgreSQL, but I can change this idea to the one you'll give me reasonable.

Upvotes: 0

Views: 86

Answers (1)

Marichyasana
Marichyasana

Reputation: 3154

Use MySQL truncate table followed by insert statement(s). https://dev.mysql.com/doc/refman/5.6/en/truncate-table.html

Upvotes: 1

Related Questions