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

How to search for a column name - Postgresql DB - New one

我正在为 openproject 使用 postgresql 数据库。我在前端网页即添加了两个自定义列。实际开始日期和实际结束日期。我需要记录项目实际日期的开始和结束时间。我不知道哪个 table 两列已创建并存储记录。我的数据库有 110 个 table,我真的很难逐一搜索每个 table。你能帮忙给我一个查询来找到这两列吗?提前致谢。

我运行以下

这为您提供架构名称以及特定列的 table 名称。

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%'

改用类似:

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