For the DBA's using a
conventional database such as oracle, they have a habit of using DESC or
DESCRIBE but in PostgreSQL, it's in different ways, we will discuss the same
here
There are 3 ways to describe a table
- using \d
- using \d+
- using view INFORMATION_SCHEMA.COLUMNS
suppose you want to see the
columns in the pg_roles table from the PostgreSQL database
\d will details of columns in
particular table as shown below
\d+ is an advanced version of \d,
it provides you the definition of the table as well.
You have another way to
describe a table i.e. using SQL query on INFORMATION_SCHEMA.COLUMNS catalog, there are a number of columns in this table, you can limit what you want to see, select * will give full details, however, I will only select the column name and its data type
select * from INFORMATION_SCHEMA.COLUMNS;
select column_name, data_type from INFORMATION_SCHEMA.COLUMNS where table_name = 'pg_roles';