zeoran zeoran - 1 month ago 5
SQL Question

how to get table name and a particular column ordinal position in entire database

I have a PostgreSQL 9.3 database called

dbSales
, It contains 150 tables most of the tables in
dbSales
have column called
product
.

So my question is How can I get table name and the column- product ordinal position in my
dbSales
?

Answer
SELECT table_name,column_name,ordinal_position 
FROM   information_schema.columns  
WHERE  table_catalog = 'dbSales' and column_name = 'product'

The information schema consists of a set of views that contain information about the objects defined in the current database.

Comments