微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

PostgreSQL View the table structure

command line

testdb=> \dt
         List of relations
 Schema |   Name    | Type  | Owner 
--------+-----------+-------+-------
 public | orderinfo | table | zwc
(1 row)

testdb=> 
testdb=> \d orderinfo
                                    Table "public.orderinfo"
    Column    |     Type     |                            Modifiers                             
--------------+--------------+------------------------------------------------------------------
 orderinfo_id | integer      | not null default nextval('orderinfo_orderinfo_id_seq'::regclass)
 customer_id  | integer      | not null
 date_placed  | date         | not null
 date_shipped | date         | 
 shipping     | numeric(7,2) | 
Indexes:
    "orderinfo_pk" PRIMARY KEY,btree (orderinfo_id)


sql

testdb=> SELECT
testdb-> A .attname AS field,testdb-> T .typname AS TYPE,testdb-> A .attlen AS LENGTH,testdb-> A .attnotnull AS NOTNULL
testdb-> FROM
testdb-> pg_class C,testdb-> pg_attribute A,testdb-> pg_type T
testdb-> WHERE
testdb-> C .relname = 'orderinfo'
testdb-> AND A .attnum > 0
testdb-> AND A .attrelid = C .oid
testdb-> AND A .atttypid = T .oid;
    field     |  type   | length | notnull 
--------------+---------+--------+---------
 orderinfo_id | int4    |      4 | t
 customer_id  | int4    |      4 | t
 date_placed  | date    |      4 | t
 date_shipped | date    |      4 | f
 shipping     | numeric |     -1 | f
(5 rows)

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐