Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialDaniel Fitzhugh
9,715 PointsWhen 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 :)
1 Answer
Adam Pengh
29,881 PointsDepends 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.
Daniel Fitzhugh
9,715 PointsDaniel Fitzhugh
9,715 PointsThanks Adam, that's very clear :)