获取表字段信息
基本信息
系统 : CentOS Linux release 7.4.1708 (Core)
产品 : OushuDB
模块 : DB
子模块 : -
描述详述
获取 表/字段/字段长度/类型/注释
原因
解决方案
SELECT n.nspname,c.relname,a.attname,length(a.attname), pg_catalog.format_type(a.atttypid, a.atttypmod), pg_catalog.col_description(a.attrelid, a.attnum) FROM pg_catalog.pg_attribute a join pg_class c on a.attrelid=c.oid join pg_namespace n on c.relnamespace=n.oid WHERE n.nspname||'.'||c.relname='SCHEMA.TABLE' AND a.attnum > 0 AND NOT a.attisdropped ORDER BY a.attnum;