如何在postgresql数据库中的所有表中查找特定的列名

如何在postgresql数据库中的所有表中查找特定的列名,postgresql,openproject,Postgresql,Openproject,我正在使用postgresql db for openproject。 我在前端网页中添加了两个自定义列,即实际开始日期和实际结束日期。 我需要记录一个项目实际日期的开始和结束。 我不知道这两列都创建了哪个表并存储了记录。 我的数据库有110个表,我很难逐个搜索每个表。 你能帮我查一下这两列吗。 提前感谢。这将为您提供架构名称以及特定列的表名 select t.table_schema, t.table_name, c.column_name from inform

我正在使用postgresql db for openproject。 我在前端网页中添加了两个自定义列,即实际开始日期和实际结束日期。 我需要记录一个项目实际日期的开始和结束。 我不知道这两列都创建了哪个表并存储了记录。 我的数据库有110个表,我很难逐个搜索每个表。 你能帮我查一下这两列吗。
提前感谢。

这将为您提供架构名称以及特定列的表名

select t.table_schema,
       t.table_name,
       c.column_name 
from information_schema.tables t
inner join information_schema.columns c on c.table_name = t.table_name 
                                and c.table_schema = t.table_schema
where c.column_name = 'column_name'
      and t.table_schema not in ('information_schema', 'pg_catalog')
      and t.table_type = 'BASE TABLE'
order by t.table_schema;

其中,“column_name”显然是您必须为列传入的名称

选择t.table\u schema、t.table\u name from information\u schema.tables t internal join information\u schema.c on c.table\u name=t.table\u name和c.table\u schema=t.table\u schema,其中c.column\u name='%actual%start%date%'和t.table\u schema不在('information\u schema',pg catalog')和t.table_type='BASE table'按t.table_模式排序;我试图获取列名,但没有得到任何结果。我更新了我的帖子,还选择了列名,以向您显示查找的列的确切名称。您现在遇到的问题是SQL标准。在字符串子句中使用像%这样的占位符会强制您不要使用等于(=),而是使用“like”子句。您必须使用“[…]其中c.column_名称,如“%actual%start%date%”[…]”