Created
November 27, 2023 10:58
-
-
Save xtrmstep/e81d4545b697088d7d2e4f53cd5b7164 to your computer and use it in GitHub Desktop.
Shows several things about PostgreSQL: how to use multi-statement query in query window, output message and use metadata
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 | |
$do$ | |
declare | |
r record; | |
query_cmd text; | |
begin | |
for r in select table_name from information_schema.tables where table_schema = 'public' and table_name like 'prefix%' | |
loop | |
query_cmd := format('delete from %s where CONDITION', r.table_name); | |
-- raise notice '%', query_cmd; | |
execute query_cmd; | |
end loop; | |
end | |
$do$; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment