• 运维笔记--postgresql查看表结构、表名、字段类型、字段注释


    连接数据库服务器,切换至postgres(或其他数据库用户)下,

    psql--进入数据库命令行终端,执行如下相关查询操作:

    显示数据库:

    l

    连接指定的数据库:

    c 数据库名

    查看当前实例下的表:

    dt

    用sql语句方式查询:

    SELECT tablename FROM pg_tables;  

    查询某张表的表结构及字段信息

    d tablename--实际表名

    用sql语句方式查询:

    SELECT a.attnum, a.attname AS field, t.typname AS type, a.attlen AS length, a.atttypmod AS lengthvar
        , a.attnotnull AS notnull, b.description AS comment
    FROM pg_class c, pg_attribute a
        LEFT JOIN pg_description b
        ON a.attrelid = b.objoid
            AND a.attnum = b.objsubid, pg_type t
    WHERE c.relname = '实际的表名'
        AND a.attnum > 0
        AND a.attrelid = c.oid
        AND a.atttypid = t.oid
    ORDER BY a.attnum;
  • 相关阅读:
    平均值的最值化
    GCJ 2008 R3 C 二分图匹配
    BZOJ 1013 高斯消元
    NOIP2015 d2T3 二分+树上前缀和
    9.7集训 总结
    BZOJ 1026
    BZOJ 3223
    NOIP前夕:codevs,关路灯
    NOIP前夕:codevs,解药还是毒药
    NOIP前夕:codevs,修剪花卉
  • 原文地址:https://www.cnblogs.com/hellojesson/p/12109312.html
Copyright © 2020-2023  润新知