Postgres – ALTER multiple TABLES
September 20, 2019
DO $$DECLARE r record; BEGIN FOR r IN SELECT tablename FROM pg_tables WHERE schemaname = ‘public’ LOOP EXECUTE ‘alter table ‘|| r.tablename ||’ owner to newowner;’; END LOOP; END$$;
DO $$DECLARE r record; BEGIN FOR r IN SELECT tablename FROM pg_tables WHERE schemaname = ‘public’ LOOP EXECUTE ‘alter table ‘|| r.tablename ||’ owner to newowner;’; END LOOP; END$$;