Welcome to the Treehouse Community
Looking to learn something new?
Daniel Fitzhugh9,715 Points
When you IMPORT a file into the database, should you DELETE what is already there first ?
Let's assume that you are managing a single Wordpress website, and you have a single database which contains all of the information for that one website. Nothing else is in this database, and you just want to overwrite the existing data with the new data.
When you import a new .SQL file into the database, should you delete what is already there first ? Or will the file that you import successfully overwrite everything that needs to be overwritten, in a similar way to what FTP does, for example ?
Hope this question makes sense :)
Adam Pengh29,880 Points
Depends on how the SQL file was generated. Typically, if you export a database to a SQL file, there will be a statement to drop the existing table and then another statement to create the table again. I would check the SQL file to see if those statements exists. If they don't and the only thing that is in the SQL file are SQL statements to insert data, then those records will be added to what is already there.
Standard practice is to drop the existing table and then create a new table with the same name and insert the records.