您好,登錄后才能下訂單哦!
今天就跟大家聊聊有關怎么在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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。