Listing all columns from a PostgreSQL database

In this short post, we are going to learn how to list all columns of every table in a PostgreSQL database.
We want to get the table schema, the name of the table, the name of the column and the data type defined for that column.


We will be using a simple SQL query, like this one:

\connect postgres
select table_schema,table_name,column_name,data_type from information_schema.columns order by column_name;

Don’t forget to change the name of the database where you want to list all the columns. So, first, connect to that database using “\connect“, inĀ  the example: “postgres“.

Leave a Reply

Your email address will not be published.