日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

postgresql表和列注释(描述)

發布時間:2023/12/10 编程问答 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 postgresql表和列注释(描述) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

2019獨角獸企業重金招聘Python工程師標準>>>

PostgreSQL添加表和列注釋。本文為測試表test,默認無注釋。

test=# \d+關聯列表架構模式 | 名稱 | 類型 | 擁有者 | 大小 | 描述 ----------+------+--------+----------+---------+------public | test | 數據表 | postgres | 0 bytes | (1 行記錄)test=# comment on table test is '測試表'; COMMENT test=# \d+關聯列表架構模式 | 名稱 | 類型 | 擁有者 | 大小 | 描述 ----------+------+--------+----------+---------+--------public | test | 數據表 | postgres | 0 bytes | 測試表 (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+關聯列表架構模式 | 名稱 | 類型 | 擁有者 | 大小 | 描述 ----------+------+--------+----------+------------+--------public | test | 數據表 | postgres | 8192 bytes | 測試表 (1 行記錄)test=# \d+ test數據表 "public.test"欄位 | 類型 | Collation | Nullable | Default | 存儲 | 統計目標 | 描述 ------+---------+-----------+----------+---------+----------+----------+------id | integer | | not null | | plain | | ID表name | text | | not null | | extended | |sex | boolean | | | true | plain | | 索引:"test_pkey" PRIMARY KEY, btree (id)test=#

刪除表和列注釋只需要將注釋信息設置為空即可。也可以使用IS NULL命令。

test=# comment on column test.id is ''; COMMENT test=# comment on table test is ''; COMMENT test=# \d關聯列表架構模式 | 名稱 | 類型 | 擁有者 ----------+------+--------+----------public | test | 數據表 | postgres (1 行記錄)test=# \d+關聯列表架構模式 | 名稱 | 類型 | 擁有者 | 大小 | 描述 ----------+------+--------+----------+------------+------public | test | 數據表 | postgres | 8192 bytes | (1 行記錄)test=# \d+ test數據表 "public.test"欄位 | 類型 | Collation | Nullable | Default | 存儲 | 統計目標 | 描述 ------+---------+-----------+----------+---------+----------+----------+------id | integer | | not null | | plain | |name | text | | not null | | extended | |sex | boolean | | | true | plain | | 索引:"test_pkey" PRIMARY KEY, btree (id)test=# #IS NULL 練習 test=# comment on column test.id is 'ID信息'; COMMENT test=# comment on table test is '測試信息'; COMMENT test=# \d+關聯列表架構模式 | 名稱 | 類型 | 擁有者 | 大小 | 描述 ----------+------+--------+----------+------------+----------public | test | 數據表 | postgres | 8192 bytes | 測試信息 (1 行記錄)test=# \d+ test數據表 "public.test"欄位 | 類型 | Collation | Nullable | Default | 存儲 | 統計目標 | 描述 ------+---------+-----------+----------+---------+----------+----------+--------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

轉載于:https://my.oschina.net/u/1011130/blog/1575956

總結

以上是生活随笔為你收集整理的postgresql表和列注释(描述)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。