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.

2
  • 1
    Does this answer your question? How to list the columns of a view in Postgres? Commented Mar 8, 2022 at 0:54
  • @bfris No, but I appreciate it. I've edited my question, hopefully to make it clear what the distinction is. Commented Mar 9, 2022 at 4:33

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.