How to list all table columns in PostgreSQL database
Aug 24th, 2021,
When working with a database you might need to list tables and their structure to have an idea about it before you start working with it, how to do that?
Well, we are going to list down various ways to list all table columns and data types
1. Using SQL Query
If you want to retrieve all tables columns in a PostgreSQL database. You can use the following SQL query:
SELECT table_schema, table_name, column_name, data_type FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = '<table_name>'
Sample results
The above query will list all the “film” table columns in the sample database:
2. Using psql command-line
To list down all tables columns on a specific table in the a PostgreSQL database using psql command-line, you can use \dS your_table_name.
3. List all table columns with ERBuilder Data Modeler
Now we will talk about ERBuilder Data Modeler which offers you the possibility to list all table columns in the PostgreSQL database with just a few clicks away.
Furthermore, with ERBuilder Data Modeler you can dive into the table details, where you can list all the columns and data types by double-clicking on the table then clicking on columns (in red). As you can see from the screenshot below, you can also edit, add new ones or delete columns.
How ERBuilder Helps
ERBuilder Data Modeler is a GUI data modeling tool that allows you to visualize, design and model databases by using entity relationship diagrams and automatically generates the most popular SQL databases including Amazon Redshift. Generate and share the data Model documentation with your team. Optimize your data model by using advanced features such as test data generation, schema compare and schema synchronization. Try now ERBuilder for 15 days FREE
Subscribe To Our Newsletter
Subscribe to our email newsletter today to receive updates of the latest news, tutorials and special offers!