0

I am interacting with a huge Postgres database that I am not familiar with. This database exposes large views with hundreds of columns each. I am supposed to get the column that contains a store ID, but I do not know the name of the column and it may be something generic (like customfield1).

Is there a way to do a reverse, by-data lookup of a column in PostgreSQL? This stackoverflow shows how to get the column names for a given view, but somehow I have to join that to the data that I search for in the table.

I want something essentially like this pseudo-sql:

select column_name from "columns_in_view" where content_of_column like "%VNMI%"

where I can test against an arbitrary string and find the column that contains data like that string.

If the only way is downloading the table as a CSV that's fine, but a SQL query is much more ideal as I do not want to expose myself to more customer information than necessary for security reasons.

I'd be open to a python solution as well.

José Mancharo
  • 175
  • 1
  • 14
  • 1
    Does this answer your question? [How to list the columns of a view in Postgres?](https://stackoverflow.com/questions/58020428/how-to-list-the-columns-of-a-view-in-postgres) – bfris Mar 08 '22 at 00:54
  • @bfris No, but I appreciate it. I've edited my question, hopefully to make it clear what the distinction is. – José Mancharo Mar 09 '22 at 04:33

0 Answers0