Home > Blockchain >  Postgres - A SQL Query to Retrieve Specific Table Names
Postgres - A SQL Query to Retrieve Specific Table Names

Time:06-18

Against a Postgres DB, I have a need to retrieve, for a specific schema SCHEMA_A, the names of all BASE_TABLES whose names start with FOO. I can successfully use the following:

SELECT * FROM information_schema.tables;

I just need it further constrained to be only BASE_TABLES starting with FOO. By the way, to the extent possible, I want to use generic SQL.

CodePudding user response:

No sure if I am missing something, but wouldn't that be a simple:

select *
from information_schema.tables
where table_type = 'BASE TABLE'
  and table_name like 'foo%'
  • Related