Created
January 7, 2015 19:07
-
-
Save chandeeland/fcce7b12afa61ea40d52 to your computer and use it in GitHub Desktop.
Dirty SQL Data Migration Technique
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- | |
-- how to populate locations table on db2 from wineries table on db1 | |
-- | |
-- SELECT "INSERT INTO locations( name, website, address, address2, city, state, zip, country, phone, created_at, updated_at, latitude, longitude, email, fax, winery_id ) VALUES (" || name ||", " || website || ", " || address || ", null , null, null, null, null, " || phone || ", " || created_at || ", " || modified_at || ",null, null, " || email || ", " || fax || ", " || winery_id || "); " FROM wineries | |
SELECT 'INSERT INTO locations( name, winery_id ) VALUES ("' || name || '", "' || winery_id || '"); ' FROM wineries | |
-- | |
-- pgsql [dbname] < dump_wineries.sql > output.sql | |
-- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment