Confused About pg_* Tables

Started by Carlos Mennensover 14 years ago4 messagesgeneral
Jump to latest
#1Carlos Mennens
carlos.mennens@gmail.com

I'm confused about how I'm able to access the following pg_* tables
regardless of connected database. I thought these tables were hidden
or stored in the 'postgres' database but I'm still able to access this
data regardless of which database I'm connected to:

Code:

zoo=# SELECT * FROM pg_user;
usename | usesysid | usecreatedb | usesuper | usecatupd | userepl |
passwd | valuntil | useconfig
----------+----------+-------------+----------+-----------+---------+----------+----------+-----------
postgres | 10 | t | t | t | t |
******** | |
carlos | 16384 | t | t | t | t |
******** | |
(2 rows)

When I use my tab key in 'psql' after the 'FROM' statement, I'm
presented with a ton of what I presume to be tables however when I
check for tables in the 'postgres' database, I get nothing. I'm
confused...

Code:

psql (9.1.1, server 9.1.1)
You are now connected to database "postgres".
postgres=# \d
No relations found.

#2Julien Rouhaud
rjuju123@gmail.com
In reply to: Carlos Mennens (#1)
Re: Confused About pg_* Tables

On Fri, Oct 14, 2011 at 6:06 PM, Carlos Mennens <carlos.mennens@gmail.com>wrote:

I'm confused about how I'm able to access the following pg_* tables
regardless of connected database. I thought these tables were hidden
or stored in the 'postgres' database but I'm still able to access this
data regardless of which database I'm connected to:

Code:

zoo=# SELECT * FROM pg_user;
usename | usesysid | usecreatedb | usesuper | usecatupd | userepl |
passwd | valuntil | useconfig

----------+----------+-------------+----------+-----------+---------+----------+----------+-----------
postgres | 10 | t | t | t | t |
******** | |
carlos | 16384 | t | t | t | t |
******** | |
(2 rows)

When I use my tab key in 'psql' after the 'FROM' statement, I'm
presented with a ton of what I presume to be tables however when I
check for tables in the 'postgres' database, I get nothing. I'm
confused...

Code:

psql (9.1.1, server 9.1.1)
You are now connected to database "postgres".
postgres=# \d
No relations found.

These objects are in the schema pg_catalog not public

#3Julien Rouhaud
rjuju123@gmail.com
In reply to: Julien Rouhaud (#2)
Re: Confused About pg_* Tables

On Fri, Oct 14, 2011 at 6:57 PM, Julien Rouhaud <rjuju123@gmail.com> wrote:

On Fri, Oct 14, 2011 at 6:06 PM, Carlos Mennens <carlos.mennens@gmail.com>wrote:

I'm confused about how I'm able to access the following pg_* tables
regardless of connected database. I thought these tables were hidden
or stored in the 'postgres' database but I'm still able to access this
data regardless of which database I'm connected to:

Code:

zoo=# SELECT * FROM pg_user;
usename | usesysid | usecreatedb | usesuper | usecatupd | userepl |
passwd | valuntil | useconfig

----------+----------+-------------+----------+-----------+---------+----------+----------+-----------
postgres | 10 | t | t | t | t |
******** | |
carlos | 16384 | t | t | t | t |
******** | |
(2 rows)

When I use my tab key in 'psql' after the 'FROM' statement, I'm
presented with a ton of what I presume to be tables however when I
check for tables in the 'postgres' database, I get nothing. I'm
confused...

Code:

psql (9.1.1, server 9.1.1)
You are now connected to database "postgres".
postgres=# \d
No relations found.

I forgot, type \dS to show system objects.

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Carlos Mennens (#1)
Re: Confused About pg_* Tables

Carlos Mennens <carlos.mennens@gmail.com> writes:

I'm confused about how I'm able to access the following pg_* tables
regardless of connected database. I thought these tables were hidden
or stored in the 'postgres' database but I'm still able to access this
data regardless of which database I'm connected to:

The underlying "pg_authid" catalog is a shared catalog that can be seen
from any database in the installation, just like pg_database. pg_user
is a view on this catalog, and so not shared in itself, but nonetheless
you'll see the same contents from every database.

regards, tom lane