加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

PostgreSQL View the table structure

发布时间:2020-12-13 17:36:24 所属栏目:百科 来源:网络整理
导读: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 -----------

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)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读