pgsql查询表中字段名,类型,备注以及是否非空 SELECT col_description ( A.attrelid, A.attnum ) AS COMMENT, format_type ( A.atttypid, A.atttypmod ) AS TYPE, A.attname AS NAME, A.attnotnull AS NOTNULL FROM pg_class AS C, pg_attribute AS A WHERE C.relname='dm_ass_gp_income'AND ...
pcolumn.numeric_scale as scale, col_description(pclass.oid, pcolumn.ordinal_position) as ColumnDescription, case when pkey.colname = pcolumn.column_name then true else false end as IsPrimaryKey, case when pcolumn.column_default like 'nextval%' then true else false end as IsIdentity, case ...
pgsql查看注释 SELECT c.relname, a.attname as 字段名, col_description(a.attrelid,a.attnum) as 注释, concat_ws('',t.typname,SUBSTRING(format_type(a.atttypid,a.atttypmod) from '(.*)')) as 字段类型, concat_ws('', ' COMMENT ON COLUMN public.', c.relname ,'.', a.attname ,'...
col_description ( A.attrelid, A.attnum ) AS COMMENT:字段注释 attrelid:字段对应的表id(与class中的oid关联) pg_description 用来存储数据库对象(如字段、表)的描述(注释)信息。 objoid:对象OID classoid:对应表 OID objsubid:如果是字段对象,则是字段序号(位置),否则为0。 descriptiontext:描述、注释内容...
col_description ( A.attrelid, A.attnum ) AS COMMENT, -- 字段备注 format_type ( A.atttypid, A.atttypmod ) AS TYPE, A.attnotnull AS NOTNULL , -- 是否非空 A.atthasdef , --是否存在默认值 A.atttypmod FROM pg_class AS C, ...
在这个查询中: pg_catalog.pg_attribute 表包含了表的字段信息。 pg_catalog.pg_class 表包含了表的信息。 pg_catalog.col_description 函数用于获取字段的注释。 请将your_table_name替换为你想要查询的表名。执行这个查询后,你将得到该表所有字段的名称及其对应的注释。
select c.relname, col_description(a.attrelid, a.attnum) as comment, format_type(a.atttypid, a.atttypmod) as type, a.attname as name, a.attnotnull as notnull from pg_class as c, pg_attribute as a where a.attrelid = c.oid and a.attnum > 0 and c.relname = 'student'; ...
col_description(pclass.oid, pcolumn.ordinal_position) as ColumnDescription, case when pkey.colname = pcolumn.column_name then true else false end as IsPrimaryKey, case when pcolumn.column_default like 'nextval%' then true else false end as IsIdentity, ...
cast(obj_description(pg_class.relfilenode,'pg_class') as varchar) as 表中文描述, '' as 表类型, '' as 表创建时间, pg_attribute.attnum as 字段编号, pg_attribute.attname as 字段名, col_description(pg_attribute.attrelid,pg_attribute.attnum) as 字段描述, ...
(二)从pg_class和pg_attribute根据指定的表名查询字段信息 SELECT C.relname, A.attname AS NAME, A.attnotnull AS NOTNULL, format_type ( A.atttypid, A.atttypmod ) AS TYPE, col_description ( A.attrelid, A.attnum ) AS COMMENT