How to display tables list in PostgreSQL | Postgres list tables | Postgres show tables | PSQL list tables | PSQL show tables | PSQL show db size

By    

Postgres list tables using PSQL PgAdmin, Postgres Show tables using PSQL

PgAdmin list tables

Open Server then click on Databases tree, then click on database which you want to see the tables list, then click Public, then click on tables menu, from there you can view tables list from PgAdmin 4.
By expanding tables menu you can view the tables list.



Postgres list tables shortcut in pgadmin using macros

We can enable macro for using shortcut keys in PostgreSQL PgAdmin. To enable macro open post gre sql query window to select the "Manage macros" menu from "Macros".

How to add macros in PgAdmin.

How to display tables list in the current database using PostgreSQL

Postgres list tables using SQL query in a database. 
SELECT  relname as "Table"
FROM 	pg_catalog.pg_statio_user_tables 
ORDER BY relname;
Using above mentioned query all user defined tables in a PostgreSQL database can list. Using macros feature we can add the shortcuts for tables list in post gre sql database. To enable macro refer How to enable macros in PgAdmin.


PostgreSQL list tables by size | Postgresql table size list
SQL query to display all table names and table size in a PostgreSQL database.
SELECT	relname 								AS "Table",
	pg_size_pretty(pg_total_relation_size(relid)) 				AS "Total Size",
	pg_size_pretty(pg_relation_size(relid)) 				AS "Data Size",
	pg_size_pretty(pg_total_relation_size(relid) - pg_relation_size(relid)) AS "Index Size"
FROM 	pg_catalog.pg_statio_user_tables 
ORDER BY pg_total_relation_size(relid) DESC;

Using above mentioned query all user defined tables list and its table size in a post gre sql database can list. Using macros feature we can add the shortcuts for tables list in PostgreSQL database. To enable macro refer How to enable macros in PgAdmin.


How to get PostgreSQL column list and datatypes of that table?

Postgres show tables using PSQL

PSQL show tables - In PSQL commands for listing tables in PostgreSQL database is

\dt

The \dt command in PSQL list tables in the database which we selected.

Postgres show tables - Using the below PSQL commands, Postgres show tables more details
\dt+
The \dt+ command in PSQL list tables along with the tables size and name of columns.

Show databases in PSQL

In PSQL commands for show databases in a PostgreSQL server is
\l
The \l command in PSQL show databases in a PostgreSQL server.

PSQL show db size 

PSQL list databases with size using below mentioned PSQL command. Postgres show databases size , database name and other details related to the databases in a PostgreSQL server
\l+

List database size postgres 

Postgres list database size using the below mentioned  SQL query.
SELECT 	t1.datname AS db_name,  
	pg_size_pretty(pg_database_size(t1.datname)) AS db_size
FROM 	pg_database t1
ORDER BY pg_database_size(t1.datname) DESC;

Please visit other related articles

PostgreSQL: Add macros in PgAdminIII
PostgreSQL: Export PostgreSQL data in to excel file
PostgreSQL: How to restrict the user access to the databases in Postgresql based on the permission
PostgreSQL: List table details using Alt+F1 in PostgreSQL
PostgreSQL: How to get ROW_COUNT of last executed query in PostgreSQL like MS SQL @@ROWCOUNT ?

0 comments