postgresql search all tables for column name 1

postgresql search all tables for column name

select table_schema,
       table_name
from information_schema.tables
where table_name like 'payment%'
      and table_schema not in ('information_schema', 'pg_catalog')
      and table_type = 'BASE TABLE'
order by table_name,
         table_schema;
Code has been copied

Here is what the above code is Doing:
1. We’re using the information_schema.tables table to get a list of all tables in the database.
2. We’re filtering the list to only include tables that start with payment.
3. We’re filtering the list to exclude tables in the information_schema and pg_catalog schemas.
4. We’re filtering the list to only include base tables.
5. We’re ordering the list by table_name and table_schema.

Similar Posts