postgresql 根据行数据查找列
我正在与一个我不熟悉的巨大 Postgres 数据库进行交互。该数据库公开了每个包含数百列的大型视图。我应该获取包含 store ID
的列,但我不知道该列的名称,它可能是通用的(例如 customfield1
)。
有没有办法对 PostgreSQL 中的列进行反向、按数据查找? 此 stackoverflow 展示了如何获取列给定视图的名称,但不知何故我必须将其连接到我在表中搜索的数据。
我想要的东西基本上像这样的伪sql:
select column_name from "columns_in_view" where content_of_column like "%VNMI%"
我可以在其中测试任意字符串并找到包含类似该字符串的数据的列。
如果唯一的方法是将表下载为 CSV 格式,那没问题,但 SQL 查询更为理想,因为出于安全原因,我不想让自己暴露在不必要的客户信息中。
我也愿意接受 python 解决方案。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论