O'Reilly logo

PostgreSQL 9 Administration Cookbook by Hannu Krosing, Simon Riggs

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How many tables in a database?

The number of tables in a relational database is a good measure of the complexity of a database, so it is a simple way to get to know any database.

How to do it...

From any interface, type in the following SQL command:

SELECT count(*) FROM information_schema.tables WHERE table_schema NOT IN ('information_schema', 'pg_catalog');

You can also look at the list of tables directly and judge whether that is a small or large number.

In psql, you can see your own tables using the following:

postgres@ebony:~/8.3/main$ psql -c "\d"
List of relations
Schema | Name | Type | Owner
--------+----------+-------+----------
public | accounts | table | postgres
public | branches | table | postgres

or in pgadmin3 you can see the tables ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required