postgresql表和列注释(描述)
生活随笔
收集整理的這篇文章主要介紹了
postgresql表和列注释(描述)
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
2019獨(dú)角獸企業(yè)重金招聘Python工程師標(biāo)準(zhǔn)>>>
PostgreSQL添加表和列注釋。本文為測(cè)試表test,默認(rèn)無注釋。
test=# \d+關(guān)聯(lián)列表架構(gòu)模式 | 名稱 | 類型 | 擁有者 | 大小 | 描述 ----------+------+--------+----------+---------+------public | test | 數(shù)據(jù)表 | postgres | 0 bytes | (1 行記錄)test=# comment on table test is '測(cè)試表'; COMMENT test=# \d+關(guān)聯(lián)列表架構(gòu)模式 | 名稱 | 類型 | 擁有者 | 大小 | 描述 ----------+------+--------+----------+---------+--------public | test | 數(shù)據(jù)表 | postgres | 0 bytes | 測(cè)試表 (1 行記錄)test=#下面演示添加列注釋。
test=# alter table test add column id int primary key; ALTER TABLE test=# alter table test add column name text not null; ALTER TABLE test=# alter table test add column sex boolean default true; ALTER TABLE test=# comment on column test.id is 'ID表'; COMMENT test=# \d+關(guān)聯(lián)列表架構(gòu)模式 | 名稱 | 類型 | 擁有者 | 大小 | 描述 ----------+------+--------+----------+------------+--------public | test | 數(shù)據(jù)表 | postgres | 8192 bytes | 測(cè)試表 (1 行記錄)test=# \d+ test數(shù)據(jù)表 "public.test"欄位 | 類型 | Collation | Nullable | Default | 存儲(chǔ) | 統(tǒng)計(jì)目標(biāo) | 描述 ------+---------+-----------+----------+---------+----------+----------+------id | integer | | not null | | plain | | ID表name | text | | not null | | extended | |sex | boolean | | | true | plain | | 索引:"test_pkey" PRIMARY KEY, btree (id)test=#刪除表和列注釋只需要將注釋信息設(shè)置為空即可。也可以使用IS NULL命令。
test=# comment on column test.id is ''; COMMENT test=# comment on table test is ''; COMMENT test=# \d關(guān)聯(lián)列表架構(gòu)模式 | 名稱 | 類型 | 擁有者 ----------+------+--------+----------public | test | 數(shù)據(jù)表 | postgres (1 行記錄)test=# \d+關(guān)聯(lián)列表架構(gòu)模式 | 名稱 | 類型 | 擁有者 | 大小 | 描述 ----------+------+--------+----------+------------+------public | test | 數(shù)據(jù)表 | postgres | 8192 bytes | (1 行記錄)test=# \d+ test數(shù)據(jù)表 "public.test"欄位 | 類型 | Collation | Nullable | Default | 存儲(chǔ) | 統(tǒng)計(jì)目標(biāo) | 描述 ------+---------+-----------+----------+---------+----------+----------+------id | integer | | not null | | plain | |name | text | | not null | | extended | |sex | boolean | | | true | plain | | 索引:"test_pkey" PRIMARY KEY, btree (id)test=# #IS NULL 練習(xí) test=# comment on column test.id is 'ID信息'; COMMENT test=# comment on table test is '測(cè)試信息'; COMMENT test=# \d+關(guān)聯(lián)列表架構(gòu)模式 | 名稱 | 類型 | 擁有者 | 大小 | 描述 ----------+------+--------+----------+------------+----------public | test | 數(shù)據(jù)表 | postgres | 8192 bytes | 測(cè)試信息 (1 行記錄)test=# \d+ test數(shù)據(jù)表 "public.test"欄位 | 類型 | Collation | Nullable | Default | 存儲(chǔ) | 統(tǒng)計(jì)目標(biāo) | 描述 ------+---------+-----------+----------+---------+----------+----------+--------id | integer | | not null | | plain | | ID信息name | text | | not null | | extended | |sex | boolean | | | true | plain | | 索引:"test_pkey" PRIMARY KEY, btree (id)test=# comment on column test.id is null; COMMENT test=# comment on table test is null; COMMENT test=#參考鏈接
http://www.postgres.cn/docs/9.6/sql-comment.html
https://www.postgresql.org/docs/current/static/sql-comment.html
轉(zhuǎn)載于:https://my.oschina.net/u/1011130/blog/1575956
總結(jié)
以上是生活随笔為你收集整理的postgresql表和列注释(描述)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: matlab拟合不显示直线,新人求助一下
- 下一篇: mysqlnavicat数据库备份与恢复