问题描述:在使用Postgres 数据库的过程中,数据库显示连接成功,使用第三方的数据库连接也正常,但是在Intelij自带的DataGrip工具中无法正常的显示Schema 和Tables信息。

使用软件:

  • Intelij 版本为 2019.3
  • Docker 版本的 Postgres 12

问题描述

每次点击更新数据库按钮,无法刷新出数据库的Tables。

image.png

并且Log控制台爆出如下错误:

12:53	Connected

12:53	select T.relkind as table_kind,
			T.relname as table_name,
			T.oid as table_id,
			T.xmin as table_state_number,
			T.relhasoids as table_with_oids,
			T.relnamespace as tablespace_id,
			T.reloptions as options,
			(select pg_catalog.array_agg(inhparent)::varchar from (select inhparent::bigint from pg_catalog.pg_inherits where T.oid = inhrelid order by inhseqno) as bts) as ancestors,
			(select pg_catalog.array_agg(inhrelid)::varchar from (select inhrelid::bigint from pg_catalog.pg_inherits where T.oid = inhparent order by inhrelid) as its) as successors,
			T.relispartition /* false */ as is_partition,
			pg_catalog.pg_get_partkeydef(T.oid) /* null */ as partition_key,
			pg_catalog.pg_get_expr(T.relpartbound, T.oid) /* null */ as partition_expression,
			pg_catalog.pg_get_userbyid(T.relowner) as "owner"
			from pg_catalog.pg_class T
			where relnamespace = ?::oid
			and relkind in ('r', 'm', 'v', 'f', 'p')
			and pg_catalog.age(T.xmin) <= pg... (show balloon)

12:53	yinxiang@localhost
			[42703] org.postgresql.util.PSQLException: ERROR: column t.relhasoids does not exist
			Position: 135.
			Error encountered  ... more

解决方案

将数据库工具中的 Option --> Introspect using JDBC metadata 按钮勾上,问题得以解决:

image.png

成功显示如下:

image.png

参考文献:

  1. PostgreSQL showing tables problem – IDEs Support (IntelliJ Platform) | JetBrains
Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐