Created
March 16, 2023 22:30
-
-
Save mchung/3f10456d64d1178fb2bbac6513ed3e46 to your computer and use it in GitHub Desktop.
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 | |
s name; | |
t name; | |
rowc bigint; | |
BEGIN | |
FOR s, t IN select table_schema, table_name | |
from information_schema.tables | |
where table_name NOT LIKE 'pg_%' | |
AND table_name NOT LIKE 'fivetran_audit' | |
AND table_schema LIKE 'a_prefix_here_%' | |
LOOP | |
EXECUTE format('delete from %I.%I where _fivetran_deleted = true', s, t); | |
EXECUTE format('select count(*) from %I.%I where _fivetran_deleted = true', s, t) into rowc; | |
raise notice '%.%: % rows', s, t, rowc; | |
END LOOP; | |
END; | |
$$ LANGUAGE plpgsql; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment