Created
January 12, 2023 18:13
-
-
Save linus-amg/4f273f57749a88f0cedfd209e66620cb 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
// this is dangerous, use with care, it truncates all tables in the current schema | |
DO $$ DECLARE | |
r RECORD; | |
BEGIN | |
FOR r IN (SELECT tablename FROM pg_tables WHERE schemaname = current_schema()) LOOP | |
EXECUTE 'TRUNCATE TABLE ' || quote_ident(r.tablename) || ' CASCADE'; | |
END LOOP; | |
END $$; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment