Answers for "postgres query to get all tables and column name"

SQL
1

postgresql get table names

SELECT table_name
  FROM information_schema.tables
 WHERE table_schema='public'
   AND table_type='BASE TABLE';
Posted by: Guest on May-26-2020
1

find a column in all tables postgres

select t.table_schema,
       t.table_name
from information_schema.tables t
inner join information_schema.columns c on c.table_name = t.table_name 
                                and c.table_schema = t.table_schema
where c.column_name = 'last_name'
      and t.table_schema not in ('information_schema', 'pg_catalog')
      and t.table_type = 'BASE TABLE'
order by t.table_schema;
Code has been copied
Posted by: Guest on June-03-2020

Code answers related to "postgres query to get all tables and column name"

Code answers related to "SQL"

Browse Popular Code Answers by Language