如何在所有表(PostgreSQL)中搜索特定值?

前端之家收集整理的这篇文章主要介绍了如何在所有表(PostgreSQL)中搜索特定值?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
一个类似的问题可用 here,但它是为Oracle。我有同样的问题Postgresql

简而言之,是否可以在Postgresql搜索每个表的每个字段以获取特定值?

谢谢。

如何转储数据库内容,然后使用grep?
$ pg_dump --data-only --inserts -U postgres your-db-name > a.tmp
$ grep United a.tmp
INSERT INTO countries VALUES ('US','United States');
INSERT INTO countries VALUES ('GB','United Kingdom');

相同的实用程序pg_dump可以在输出包括列名。只需更改 – 插入到 – 列插入。这样,你也可以搜索特定的列名。但是如果我正在寻找列名,我可能会转储模式而不是数据。

$ pg_dump --data-only --column-inserts -U postgres your-db-name > a.tmp
$ grep country_code a.tmp
INSERT INTO countries (iso_country_code,iso_country_name) VALUES ('US','United  States');
INSERT INTO countries (iso_country_code,iso_country_name) VALUES ('GB','United Kingdom');
原文链接:https://www.f2er.com/postgresql/193691.html

猜你在找的Postgre SQL相关文章