I'm new to PostgreSQL and I'm trying to change the table owner for a bunch of tables. I was able to change the ownership by logging in a the postgres user and executing alter table owner to user1
, but when I login as user1 it still shows postgres as the owner. For instance, when logged in as the postgres user and executing \dt
or select * from pg_tables where tableowner = 'user1'
it shows user1 as the owner, but when I login as user1 and do the same thing it still shows postgres as the table owner. I've tried restarting the service and that didn't change anything. What am I missing?
Postgresql – Postgres Table Ownership
postgresql
Related Question
- PostgreSQL Large Objects and Multiple Users
- PostgreSQL Permissions – GRANT ALL ON ALL TABLES IN SCHEMA Not Allowing User to See Tables
- Postgresql – Postgres 10.5: Granting full schema access to a user that isn’t the owner
- Postgres 10 System-Wide Startup File on Ubuntu 18.04
- Postgresql – Unable to alter partition table to set logged
- Postgresql – Changing Table Ownership in Postgres from Postgres User
Best Answer
You must be seeing different tables from different database clusters, databases or schemas.
Either you are logging into a different database by mistake or you got yourself confused with tables of the same name in different schemas of the same database.
The latter would typically happen with two different roles that have different
search_path
settings or even the (default) setting:Without schema-qualification, tables of the same name are found in the "current" schema first ...
Your test would also find the "wrong" table:
Test instead with:
You should see two or more rows for the same table name ...
Of just use schema-qualified table names to avoid possible confusion:
Start by reading about schemas in the manual.