Created
November 8, 2010 10:55
-
-
Save ramontayag/667574 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
CREATE OR REPLACE FUNCTION clone_schema_data(source_schema text, dest_schema text) RETURNS void AS | |
$BODY$ | |
DECLARE | |
objeto text; | |
BEGIN | |
FOR objeto IN | |
SELECT table_name::text FROM information_schema.TABLES WHERE table_schema = source_schema | |
LOOP | |
IF objeto != 'schema_migrations' THEN | |
EXECUTE 'INSERT INTO ' || dest_schema || '.' || objeto || '(SELECT * FROM ' || source_schema || '.' || objeto || ')'; | |
END IF; | |
END LOOP; | |
END; | |
$BODY$ | |
LANGUAGE plpgsql VOLATILE; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment