How to replace whole table


Problem :

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.



Solution :

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


Mysql Tutorials

Mysql Howto..

How to do MySQL + Substring? + replace?

How to find missing IDs in MySQL table [duplicate]

How to optimize mysql group by with order by

How to extract numbers from a text field in MySQL

How to use MySQL index columns?

How do you deal with the fact that default parameters are not possible for Mysql SPs?

How to calculate the value of string in mysql [closed]

How to get hold of Amazon MySQL RDS certificates

Django: How can you stop long queries from killing your database? [closed]

How do I in MySQL organize groups of hierarchical data from a single table?

Pythonistas, how do I move data from top to bottom to left to right in MySQL (think multiple values for each ID)?

How to control my last import in MySQL

How to copy fields for one table to another table on Mysql? [duplicate]

How to validate a MYSQL Date in PHP?

Simple password encryption - how do i do? [closed]

How to write Nhibernate Query C# .net Mysql

How to select all records that are 10 minutes within current timestamp in MySQL?

MYSQL - sort a list, how to always have one result at the end?

How can I take the results of two database rows and condense them into a single row?

How to update .ToList() in Controller to point to a different table?

How to add the SphinxSE Plugin to a Percona XtraDB Cluster?

How to tie up MySQL tables properly

How can I best model this as a Database?

How to use GROUP BY after the Having clause Mysql

How to remove multi-level menu item with children in MySQL?

How to use new format

How to insert data from Python program to MySQL database at intervals

How to use SSH input mysql database?

How to exclude some values in sorting with MySQL?

MySQL command-line tool: How to find out number of rows affected by a DELETE?