查询以识别 postgresql 数据库表中使用的所有数据类型

Phi*_*ord 6 postgresql datatypes information-schema

我不想知道所有数据类型,只想知道我的数据库中使用的所有数据类型。这个信息可以查询吗?

PostgreSQL 8.4 和 9.x 版本

我目前需要知道公共(和其他模式)中 200 多个表的所有数据类型

suf*_*leR 11

select data_type, count(*) 
from information_schema.columns 
where table_schema = 'public' 
group by data_type ;
Run Code Online (Sandbox Code Playgroud)

对于其他模式,只需添加:或 table_schema = 'your_schema_name'。
如果这不能满足您,您应该查看 pg_... 或 information_schema 表。

如果您正在寻找表格信息:

select data_type, count(*)
from information_schema.columns
where table_schema = 'public' and table_name = 'your_table_name'
group by data_type ;
Run Code Online (Sandbox Code Playgroud)