Saturday 18 May 2019

Postgres: List all the tables


\d command is used to list all table in a database.

Step 1: Create a database myOrg.
createdb -U postgres -h localhost myOrg

Step 2: Login to myOrg database and execute the command \d to list all the tables in this database.
$psql -U postgres -h localhost --dbname=myOrg
Password for user postgres: 
psql (14.4)
Type "help" for help.

myOrg=# 
myOrg=# \d
Did not find any relations.
 

Create table employee.

CREATE TABLE employee (id INT, name VARCHAR(20));

myOrg=# CREATE TABLE employee (id INT, name VARCHAR(20));
CREATE TABLE
myOrg=# 
myOrg=# \d
          List of relations
 Schema |   Name   | Type  |  Owner   
--------+----------+-------+----------
 public | employee | table | postgres
(1 row)


Previous                                                 Next                                                 Home

No comments:

Post a Comment