do $$
declare
addcolumn record;
dm_schema VARCHAR(8) := ‘sales_dm';
begin
for addcolumn in
select
'ALTER TABLE '|| dm_schema ||'.'|| T.targettable || ' ADD COLUMN IF NOT EXISTS last_modified_timestamp timestamp NULL' as sqlscript
from
(
select tablename as targettable from pg_tables where schemaname = dm_schema
) t
loop
execute addcolumn.sqlscript;
end loop;
end;
$$;
No comments:
Post a Comment