Notification texts go here Contact Us Buy Now!

PostgreSQL query to list all table names?

Here is a PostgreSQL query to list all table names:

SELECT table_name
FROM information_schema.tables
WHERE table_schema='public'
AND table_type='BASE TABLE';

This query uses the information_schema.tables view to get a list of all tables in the current database. The table_schema column specifies the schema that the table belongs to, and the table_type column specifies the type of table (e.g., BASE TABLE, VIEW, etc.).

Here are some other ways to list all table names in PostgreSQL:

\d

This command will list all tables in the current database.

SELECT * FROM pg_tables WHERE schemaname = 'public';

This query will list all tables in the public schema.

SELECT table_name FROM pg_stat_user_tables WHERE schemaname = 'public';

This query will list all tables in the public schema that have been accessed by the current user.

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.