Reputation: 753
I'd like to dump the old database, and repopulate the new DB.
... But only if the new database has a given column
Example:
old_DB User table has 5 columns : Login, Email, City, State, Phone
new_DB User table has columns : Login, Email, Phone
Is there a mass operation which I can run to ONLY populate Login, Email and Phone only ?
Upvotes: 0
Views: 224
Reputation: 753
So a modified working version of Marc B's statement is here:
INSERT INTO asdf_mock.citations_sites (`citation_id`, `site_id`, `created_at`, `updated_at`)
SELECT `citation_id`, `site_id`, `created_at`, `updated_at`
FROM asdf_production.citations_sites;
Running this with the back-tick quotes gives the desired insertion.
Upvotes: 0
Reputation: 360572
Assuming the two DBs are running within the same mysql instance, you can do
INSERT INTO newdb.newtable (field1, field2, ....)
SELECT FROM olddb.oldtable (field1, field2, ...)
as a single query. No need to use a dump. Relevant docs here: http://dev.mysql.com/doc/refman/5.1/en/insert-select.html
Upvotes: 3