In my public schema I have 1200 tables. Somewhere in one or more of this tables there are some fields called LIKE "active" like: - status_active - hr_active - who_knows_what_active_could_be
I want to find them all using PGAdmin in the console or via the normal client on console how could I do this with quick with less resources?
All system tables and views in the pg_catalog schema (including pg_tables ) are completely Postgres specific. Queries using those will never run on other DBMS products. The INFORMATION_SCHEMA views use those system views and tables to collect and present the metadata as required by the SQL standard.
Try:
SELECT *
FROM information_schema.columns
WHERE TRUE
AND table_schema = 'public'
AND column_name ~* 'active'
You can try:
SELECT table_name,tables.table_catalog,tables.table_schema,column_name
FROM information_schema.columns
inner join information_schema.tables
using(table_name,table_schema)
WHERE table_type = 'BASE TABLE'
and column_name ilike '%active%'
select * from INFORMATION_SCHEMA.COLUMNS
where TABLE_SCHEMA = 'your schema name'
--and TABLE_NAME ilike '%your keyword%' --when you need to search for a TABLE
and COLUMN_NAME ilike '%your keyword%' --when you need to search for a COLUMN
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With