Created
September 5, 2022 12:51
-
-
Save anhtran/8b79e4e79161126394282e7e4a0334ef to your computer and use it in GitHub Desktop.
Drop all tables with prefix use wildcard - Xóa toàn bộ bảng bắt đầu bằng tiền tố bất kỳ trong PostgreSQL (psql)
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
# remove all tables start with "django_" | |
DO $$ DECLARE | |
r RECORD; | |
BEGIN | |
FOR r IN (SELECT tablename FROM pg_tables WHERE tablename like 'django_%') LOOP | |
EXECUTE 'DROP TABLE IF EXISTS ' || 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