Skip to content

Instantly share code, notes, and snippets.

@jitscar
Last active March 7, 2019 11:57
Show Gist options
  • Save jitscar/9aad1ce80d803937e1597a9c8261b1a1 to your computer and use it in GitHub Desktop.
Save jitscar/9aad1ce80d803937e1597a9c8261b1a1 to your computer and use it in GitHub Desktop.
Clean all data in PostreSql db
do
$$
declare
l_stmt text;
begin
select 'TRUNCATE ' || string_agg(format('%I.%I', schemaname, tablename), ',')
into l_stmt
from pg_tables
where schemaname in ('public', 'sources');
execute l_stmt || ' CASCADE';
end;
$$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment