Show tables in PostgreSQL

We can get all tables of a database using following methods.

\dt –> To get user tables
\dt * –> To get all tables user tables and system tables
SELECT * FROM pg_catalog.pg_tables; –> To get all tables user tables and system tables

k2info=# \dt List of relations Schema | Name | Type | Owner --------+----------+-------+-------------- public | dept | table | enterprisedb public | emp | table | enterprisedb public | student | table | enterprisedb public | students | table | enterprisedb public | test | table | enterprisedb (5 rows) k2info=# \dt * List of relations Schema | Name | Type | Owner ------------+---------------------------+-------+-------------- pg_catalog | edb_dir | table | enterprisedb pg_catalog | edb_partdef | table | enterprisedb pg_catalog | edb_partition | table | enterprisedb pg_catalog | edb_policy | table | enterprisedb pg_catalog | edb_resource_group | table | enterprisedb pg_catalog | edb_variable | table | enterprisedb pg_catalog | pg_aggregate | table | enterprisedb pg_catalog | pg_am | table | enterprisedb pg_catalog | pg_amop | table | enterprisedb pg_catalog | pg_amproc | table | enterprisedb pg_catalog | pg_attrdef | table | enterprisedb pg_catalog | pg_attribute | table | enterprisedb pg_catalog | pg_auth_members | table | enterprisedb pg_catalog | pg_authid | table | enterprisedb pg_catalog | pg_cast | table | enterprisedb pg_catalog | pg_class | table | enterprisedb pg_catalog | pg_collation | table | enterprisedb pg_catalog | pg_constraint | table | enterprisedb pg_catalog | pg_conversion | table | enterprisedb pg_catalog | pg_database | table | enterprisedb k2info=# SELECT * FROM pg_catalog.pg_tables; schemaname | tablename | tableowner | tablespace | hasindexes | hasrules | hastriggers --------------------+---------------------------+--------------+------------+------------+----------+------------- pg_catalog | pg_statistic | enterprisedb | | t | f | f pg_catalog | pg_type | enterprisedb | | t | f | f public | students | enterprisedb | | f | f | f public | student | enterprisedb | | f | f | f public | test | enterprisedb | | f | f | f pg_catalog | pg_authid | enterprisedb | pg_global | t | f | f pg_catalog | pg_proc | enterprisedb | | t | f | f pg_catalog | pg_database | enterprisedb | pg_global | t | f | f public | dept | enterprisedb | | t | f | t

You can leave a response, or trackback from your own site.

Leave a Reply

Powered by k2schools