<kbd id="9plqc"><label id="9plqc"></label></kbd>

        <th id="9plqc"></th>
        1. <center id="9plqc"><video id="9plqc"></video></center>
          <sub id="9plqc"><form id="9plqc"><pre id="9plqc"></pre></form></sub>
          <nav id="9plqc"><form id="9plqc"><legend id="9plqc"></legend></form></nav>
          PostgreSQL 您所在的位置:網(wǎng)站首頁 屬羊的孩子今年幾周歲了 PostgreSQL

          PostgreSQL

          2024-09-14 16:44| 來源: 網(wǎng)絡(luò)整理| 查看: 265

          前言

          PostgreSQL的表一般都是建立在public這個schema下的,假如現(xiàn)在有個數(shù)據(jù)表t_student,可以用以下幾種方式來查詢表結(jié)構(gòu)和索引信息。

          使用\d元命令查看表字段信息和索引信息

          在cmd界面使用psql連接db后,輸入\d加上表名即可:

          \d t_student 通過系統(tǒng)數(shù)據(jù)字典查詢表結(jié)構(gòu) select col.table_schema, col.table_name, col.ordinal_position, col.column_name, col.data_type, col.character_maximum_length, col.numeric_precision, col.numeric_scale, col.is_nullable, col.column_default, des.description from information_schema.columns col left join pg_description des on col.table_name::regclass = des.objoid and col.ordinal_position = des.objsubid where table_schema = 'public' and table_name = 't_student' order by ordinal_position;

          或者簡單點:

          select * from information_schema.columns where table_schema='public' and table_name='t_student'; 通過系統(tǒng)數(shù)據(jù)字典查詢索引信息 select A.SCHEMANAME, A.TABLENAME, A.INDEXNAME, A.TABLESPACE, A.INDEXDEF, B.AMNAME, C.INDEXRELID, C.INDNATTS, C.INDISUNIQUE, C.INDISPRIMARY, C.INDISCLUSTERED, D.DESCRIPTION from PG_AM B left join PG_CLASS F on B.OID = F.RELAM left join PG_STAT_ALL_INDEXES E on F.OID = E.INDEXRELID left join PG_INDEX C on E.INDEXRELID = C.INDEXRELID left outer join PG_DESCRIPTION D on C.INDEXRELID = D.OBJOID, PG_INDEXES A where A.SCHEMANAME = E.SCHEMANAME and A.TABLENAME = E.RELNAME and A.INDEXNAME = E.INDEXRELNAME and E.SCHEMANAME = 'public' and E.RELNAME = 't_student'; 查詢所有的表名 select n.nspname, relname from pg_class c, pg_namespace n where c.relnamespace = n.oid and nspname = 'public' and relkind = 'r' order by relname; 可視化工具DBeaver

          對于上述的sql語句只需要修改要查詢的table name,可以根據(jù)需要自行修改想要查詢的column。如果是通過DBeaver來連接數(shù)據(jù)庫,還可以直接在當(dāng)前的數(shù)據(jù)庫實例下打開schema里的public選項,接著選中table,選中你想查看的表,可以很直觀地看到該表的各種信息:column、index等等。

          參考鏈接 PostgreSQL:如何查詢表的字段信息?


          【本文地址】

          公司簡介

          聯(lián)系我們

          今日新聞

          推薦新聞

          專題文章
            CopyRight 2018-2019 實驗室設(shè)備網(wǎng) 版權(quán)所有
            黄色免费网站在线看,韩国精品在线观看,韩国美女一区二区,99国产热 佛教| 嵊泗县| 临沂市| 肃南| 新疆| 通渭县| 定边县| 沈丘县| 华安县| 怀安县| 黎川县| 孙吴县| 保康县| 炉霍县| 黄骅市| 平泉县| 昌黎县| 吉水县| 金门县| 化德县| 芜湖县| 潜山县| 大安市| 兰坪| 榆林市| 岳阳县| 永泰县| 米林县| 宜宾县| 济南市| 海原县| 裕民县| 通许县| 和平区| 新蔡县| 三台县| 富顺县| 泾阳县| 商都县| 确山县| 凤山县| http://444 http://444 http://444 http://444 http://444 http://444