How to get list of tables in PostgreSQL

As a routine database admistration task, administrators used to check the list of databases in the server and list of tables in available in currently connected database. In this tutorial, we will learn how to get list of tables in current connected database.

To get list of tables in list of tables in PostgreSQL database.

1. Connect to the database

\c edb

You are now connected to database “edb” as user “enterprisedb”.

2. Get the list of tables type \dt and press enter psql shell(Postgresql Workspace)

\dt

List of relations Schema | Name | Type | Owner --------------+---------+-------+-------------- enterprisedb | edb1 | table | enterprisedb public | dept | table | enterprisedb public | emp | table | enterprisedb public | jobhist | table | enterprisedb (4 rows)

3. If we want to know all the objects in current database type \d and press enter psql shell

\d

List of relations Schema | Name | Type | Owner --------------+------------+----------+-------------- enterprisedb | edb1 | table | enterprisedb public | dept | table | enterprisedb public | emp | table | enterprisedb public | jobhist | table | enterprisedb public | next_empno | sequence | enterprisedb public | salesemp | view | enterprisedb (6 rows)

How to get list of tables in PostgreSQL

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

Leave a Reply

Powered by k2schools