K
K
kolomiec_artiom2020-09-08 11:22:40
PostgreSQL
kolomiec_artiom, 2020-09-08 11:22:40

How to see if a column exists in at least some table of the current schema?

Hello! I have a schema that has a fairly large number of tables. How can I check that at least one table has the column I need?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Melkij, 2020-09-08
@kolomiec_artiom

select table_name from information_schema.columns where column_name = ? and table_schema = ?;

Or the same through native pg_attribute.

E
Evgeny Matveev, 2020-09-08
@ematveev

the algorithm is simple: get a list of tables and check each one :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question