1) pg_dump -s YOUR_DB | grep -i 'owner to' | \
sed -e 's/OWNER TO .*;/OWNER TO NEW_OWNER;/i' | \
psqL YOUR_DB
2)
TablesSELECT 'ALTER TABLE '|| schemaname || '.' || tablename ||' OWNER TO my_new_owner;'
FROM pg_tables WHERE NOT schemaname IN ('pg_catalog', 'information_schema')
ORDER BY schemaname, tablename;
Sequences
SELECT 'ALTER SEQUENCE '|| sequence_schema || '.' || sequence_name ||' OWNER TO my_new_owner;'
FROM information_schema.sequences WHERE NOT sequence_schema IN ('pg_catalog', 'information_schema')
ORDER BY sequence_schema, sequence_name;
ViewsSELECT 'ALTER VIEW '|| table_schema || '.' || table_name ||' OWNER TO my_new_owner;'
FROM information_schema.views WHERE NOT table_schema IN ('pg_catalog', 'information_schema')
ORDER BY table_schema, table_name;
This generates all the required
ALTER TABLE
/ ALTER SEQUENCE
/ ALTER VIEW
statements, copy these and paste them back into plsql to run them.Check your work in psql by doing:
\dt *.*
\ds *.*
\dv *.*
Комментариев нет:
Отправить комментарий
Примечание. Отправлять комментарии могут только участники этого блога.