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.