List the database, schema, tables, users, views & roles in PostgreSQL

Check the database, schema , views, tables, users & roles in PostgreSQL

Check the database present in the PostgreSQL:

\l

Check the list of tables present in the PostgreSQL:

\dt

Example:
testdb=# \dt
        List of relations
 Schema | Name | Type  |  Owner
--------+------+-------+----------
 public | test | table | postgres
(1 row)

Check the views present in the PostgreSQL:

\dv

Check the list of function present in the PostgrSQL:

\df

Check the list of schemas present in the PostgrSQL:

\dn

Example:
testdb=# \dn
      List of schemas
  Name  |       Owner
--------+-------------------
 public | pg_database_owner
(1 row)

Check the list of user present in the PostgreSQL:

\du

Example:
postgres=# \du
                                   List of roles
 Role name |                         Attributes                         | Member of
-----------+------------------------------------------------------------+-----------
 postgres  | Superuser, Create role, Create DB, Replication, Bypass RLS | {}

This entry was posted in PostgreSQL on by .
Unknown's avatar

About SandeepSingh

Hi, I am working in IT industry with having more than 15 year of experience, worked as an Oracle DBA with a Company and handling different databases like Oracle, SQL Server , DB2 etc Worked as a Development and Database Administrator.

Leave a Reply