If you need to transfer ownership of whole database (in postgress) you need to alter all tables, sequnces, views, and materialized views separately.
Below is script generets it's for you. Just type in the my.vars.new_owner
name of the role to which you want to transfer ownerships.
set session my.vars.new_owner = 'new_owner_role';
select current_setting('my.vars.new_owner');
alter database {database_name} owner to current_setting('my.vars.new_owner');
SELECT 'ALTER TABLE ' || schemaname || '."' || tablename || '" OWNER TO ' || current_setting('my.vars.new_owner') || ';'
FROM pg_tables
WHERE NOT schemaname IN ('pg_catalog', 'information_schema')
ORDER BY schemaname, tablename;
SELECT 'ALTER SEQUENCE ' || sequence_schema || '."' || sequence_name || '" OWNER TO ' || current_setting('my.vars.new_owner') || ';'
FROM information_schema.sequences
WHERE NOT sequence_schema IN ('pg_catalog', 'information_schema')
ORDER BY sequence_schema, sequence_name;
SELECT 'ALTER VIEW ' || table_schema || '."' || table_name || '" OWNER TO ' || current_setting('my.vars.new_owner') || ';'
FROM information_schema.views
WHERE NOT table_schema IN ('pg_catalog', 'information_schema')
ORDER BY table_schema, table_name;
SELECT 'ALTER TABLE ' || oid::regclass::text || ' OWNER TO ' || current_setting('my.vars.new_owner') || ';'
FROM pg_class
WHERE relkind = 'm'
ORDER BY oid;