Last active
September 13, 2017 13:37
-
-
Save klapuch/bec5cc3de2e232f665c3c13409ec3639 to your computer and use it in GitHub Desktop.
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
CREATE FUNCTION restart_sequences() RETURNS VOID AS $$ | |
DECLARE | |
public_schema CONSTANT INTEGER NOT NULL DEFAULT 2200; | |
statements CURSOR FOR SELECT 'ALTER SEQUENCE ' || relname || ' RESTART;' AS query | |
FROM pg_class | |
WHERE relkind = 'S' | |
AND relnamespace = public_schema; | |
BEGIN | |
FOR stmt IN statements LOOP | |
EXECUTE stmt.query; | |
END LOOP; | |
END; | |
$$ LANGUAGE plpgsql; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment