PostgreSQL 14に作成済みのスキーマ一覧を取得する

環境
Windows10 64 bit
PostgreSQL 14.1

操作方法
1.「\dn」コマンドを使用して、作成済みのスキーマ一覧を取得します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
postgres=# \dn
スキーマ一覧
名前 | 所有者
-----------+----------
cfschema | postgres
cftschema | cft055
public | postgres
testcft | postgres
(4)
postgres=# \dn スキーマ一覧 名前 | 所有者 -----------+---------- cfschema | postgres cftschema | cft055 public | postgres testcft | postgres (4 行)
postgres=# \dn
     スキーマ一覧
   名前    |  所有者
-----------+----------
 cfschema  | postgres
 cftschema | cft055
 public    | postgres
 testcft   | postgres
(4 行)

2.システムカタログからスキーマを取得します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
postgres=# select nspname, nspowner, nspacl from pg_namespace;
nspname | nspowner | nspacl
--------------------+----------+-------------------------------------
pg_toast | 10 |
pg_temp_1 | 10 |
pg_toast_temp_1 | 10 |
pg_catalog | 10 | {postgres=UC/postgres,=U/postgres}
public | 10 | {postgres=UC/postgres,=UC/postgres}
information_schema | 10 | {postgres=UC/postgres,=U/postgres}
testcft | 10 |
cfschema | 10 |
cftschema | 55493 | {cft055=UC/cft055}
(9)
postgres=# select nspname, nspowner, nspacl from pg_namespace; nspname | nspowner | nspacl --------------------+----------+------------------------------------- pg_toast | 10 | pg_temp_1 | 10 | pg_toast_temp_1 | 10 | pg_catalog | 10 | {postgres=UC/postgres,=U/postgres} public | 10 | {postgres=UC/postgres,=UC/postgres} information_schema | 10 | {postgres=UC/postgres,=U/postgres} testcft | 10 | cfschema | 10 | cftschema | 55493 | {cft055=UC/cft055} (9 行)
postgres=# select nspname, nspowner, nspacl from pg_namespace;
      nspname       | nspowner |               nspacl
--------------------+----------+-------------------------------------
 pg_toast           |       10 |
 pg_temp_1          |       10 |
 pg_toast_temp_1    |       10 |
 pg_catalog         |       10 | {postgres=UC/postgres,=U/postgres}
 public             |       10 | {postgres=UC/postgres,=UC/postgres}
 information_schema |       10 | {postgres=UC/postgres,=U/postgres}
 testcft            |       10 |
 cfschema           |       10 |
 cftschema          |    55493 | {cft055=UC/cft055}
(9 行)

項目説明
nspname 名前空間の名前
nspowner 名前空間の所有者
nspacl アクセス権限の一覧

PostgreSQL

Posted by arkgame