今天就跟大家聊聊有关怎么在postgresql中查询字段的表,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。
SELECT * FROM information_schema. COLUMNS WHERE COLUMN_NAME = 'storename';
SELECT c.relname AS "表名",a.attname AS "字段名",c.oid FROM pg_class c LEFT JOIN pg_attribute a ON a.attrelid = c.oid WHERE c.relname NOT LIKE 'pg_%' -- AND c.relname = 'kx_store' AND a.attname = 'storename';
补充:postgresql数据库查询所有字段详细信息,包括描述
把里边的public改成相应模式名(默认为public,可不改)
table_name改成对应表名称
SELECT AA.*,BB.DESC FROM ( SELECT A.ORDINAL_POSITION AS COL_NUM, A.COLUMN_NAME AS COL_NAME, A.DATA_TYPE AS COL_TYPE, A.CHARACTER_MAXIMUM_LENGTH AS COL_LEN, A.NUMERIC_PRECISION AS COL_PREC, A.DATETIME_PRECISION AS COL_TIME_PREC, A.IS_NULLABLE AS COL_NULLABLE, A.COLUMN_DEFAULT AS COL_DEFAULT FROM INFORMATION_SCHEMA.COLUMNS A WHERE A.TABLE_SCHEMA = 'public' AND A.TABLE_NAME = 'table_name' ) AS AA LEFT JOIN ( SELECT OBJSUBID, DESCRIPTION AS DESC FROM PG_DESCRIPTION WHERE OBJOID = ( SELECT RELID FROM PG_STAT_ALL_TABLES WHERE SCHEMANAME = 'public' AND RELNAME = 'table_name' ) ) AS BB ON AA.COL_NUM = BB.OBJSUBID ORDER BY AA.COL_NUM;
看完上述内容,你们对怎么在postgresql中查询字段的表有进一步的了解吗?如果还想了解更多知识或者相关内容,请关注亿速云行业资讯频道,感谢大家的支持。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。