Last active
August 29, 2015 14:23
-
-
Save nuklea/0c4e05d86ffa6aaed93b to your computer and use it in GitHub Desktop.
Dynamic table name in query
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
DO $$ | |
DECLARE | |
r record; | |
BEGIN | |
FOR r IN SELECT tablename FROM pg_catalog.pg_tables WHERE tablename LIKE 'schema_%%' LOOP | |
EXECUTE 'UPDATE ' || quote_ident(r.tablename) || ' SET host_added = ''54auto.ru'' WHERE host_added = ''54.ruauto.ru'''; | |
END LOOP; | |
END $$ LANGUAGE plpgsql; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment