Is there any way by which I can get the total number of tables in a Postgresql database? The postgresql version I'm using is PostgreSQL 8.4.14.
Use the \dt or \dt+ command in psql to show tables in a specific database. Use the SELECT statement to query table information from the pg_catalog.
Technically Postgres does not have a limit on the number of tables. However, each table is a file on the OS filesystem. And the OS probably has some opinion on how many files is "too many".
Use \l or \l+ in psql to show all databases in the current PostgreSQL server. Use the SELECT statement to query data from the pg_database to get all databases.
select count(*) from information_schema.tables;
Or if you want to find the number of tables only for a specific schema:
select count(*) from information_schema.tables where table_schema = 'public';
Just try to search in pg_stat... tables or information_schema you can find there very useful informations about your database.
Example:
select * from pg_stat_user_tables ; select count(*) from pg_stat_user_tables ; select * from pg_stat_all_tables ;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With