如何搜索列名-Postgresql DB-新建

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

我正在使用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”显然是您必须为列传入的名称。我运行了下面的查询

select t.table_schema,
       t.table_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 = '%actual%start%date%'
      and t.table_schema not in ('information_schema', 'pg_catalog')
      and t.table_type = 'BASE TABLE' order by t.table_schema;

但是我没有从数据库中得到任何答案。

您使用了带有等式(=)运算符的通配符:

c.column_name = '%actual%start%date%'
改用like:

c.column_name like '%actual%start%date%'

由于您知道所需的确切列名,因此无需使用通配符查找。只需c.column\u name='actual\u start\u date'