大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
今天就跟大家聊聊有关怎么在postgresql中查询字段的表,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。
成都创新互联-专业网站定制、快速模板网站建设、高性价比江北网站开发、企业建站全套包干低至880元,成熟完善的模板库,直接使用。一站式江北网站制作公司更省心,省钱,快速模板网站建设找我们,业务覆盖江北地区。费用合理售后完善,10多年实体公司更值得信赖。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中查询字段的表有进一步的了解吗?如果还想了解更多知识或者相关内容,请关注创新互联行业资讯频道,感谢大家的支持。