Created
November 22, 2021 05:27
-
-
Save yuhangch/6dc113d49bcdd0bf82bc7ae42ac33604 to your computer and use it in GitHub Desktop.
Postgresql delete all table in a scheme exclude 'spatial_ref_sys'
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
DO $$ DECLARE | |
r RECORD; | |
BEGIN | |
FOR r IN (SELECT tablename FROM pg_tables WHERE (schemaname = current_schema() and tablename != 'spatial_ref_sys')) 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