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 ...
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:描述、注释内容...
(casewhena.attnotnull=truethen'是'else'否'end)asnullable, col_description(a.attrelid,a.attnum)ascommentfrompg_attribute awhereattstattarget=-1andattrelidin(selectoidfrompg_classwhererelnamein(selectrelnamefrompg_classwhererelkind='r'andrelnamein(selecttablenamefrompg_tableswheretablenamenotlike'pg...
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 字段描述, ...
where relkind = 'r' and relname not like 'pg_%' and relname not like 'sql_%' order by relname 过滤掉分表: 加条件 and relchecks=0 即可 获取字段名、类型、注释、是否为空: SELECT col_description(a.attrelid,a.attnum) as comment,format_type(a.atttypid,a.atttypmod) as type,a.attna...
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, ...
select relname as TABLE_NAME ,col_description(c.oid, 0) as COMMENTS from pg_class c where relkind = 'r' and relname not like 'pg_%' and relname not like 'sql_%' 四、获取数据大小 1、查询执行数据库大小 select pg_size_pretty (pg_database_size('db_product')); ...
col_description(a.attrelid,a.attnum) as "注释", concat_ws('',t.typname,SUBSTRING(format_type(a.atttypid,a.atttypmod) from '(.*)')) as "字段类型" FROM pg_class as c, pg_attribute as a, pg_type as t WHERE c.relname = 't_batch_task' ...