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.