環境
ユーザー scott
データベース city
city というデータベースに、city というスキーマを作成します。
コメントの付加
set_comment.sql
comment on schema city is '都市名';
実行コマンド
psql -U scott city < set_comment.sql
コメントの確認
get_comment.sql
SELECT n.nspname AS schema_name, d.description
FROM pg_catalog.pg_namespace n
LEFT JOIN pg_catalog.pg_description d ON d.objoid = n.oid AND d.objsubid = 0;
実行コマンド
psql -U scott city < get_comment.sql
実行結果
$ psql -U scott city < get_comment.sql
schema_name | description
--------------------+----------------------------------
pg_toast | reserved schema for TOAST tables
pg_catalog | system catalog schema
public | standard public schema
information_schema |
city | 都市名
(5 rows)
別の確認方法
$ psql -U scott city
psql (16.2 (Ubuntu 16.2-1ubuntu4), server 14.8 (Ubuntu 14.8-0ubuntu0.22.10.1))
Type "help" for help.
city=# select * from pg_description where objoid = (SELECT oid FROM pg_catalog.pg_namespace WHERE nspname = 'city');
objoid | classoid | objsubid | description
--------+----------+----------+-------------
93405 | 2615 | 0 | 都市名
(1 row)
city=#