【PostgreSQL】PostgreSQLのスキーマあれこれ

■ はじめに

恥ずかしながら、PostgreSQLのスキーマとDBが一緒なものだと
思っていた、、、
そんな自戒な意味を込めて、PostgreSQLのスキーマについて
学んでおく。

目次

【1】スキーマ (Schema)
【2】構文

【1】スキーマ (Schema)

* 名前空間 を設定する感じ
* DB => Schema => Table のように管理されているイメージ

【2】構文

https://www.postgresql.jp/document/9.2/html/sql-createschema.html
https://www.dbonline.jp/postgresql/schema/index2.html#section1

スキーマ作成

CREATE SCHEMA [schema_name];

-- スキーマの所有者の設定
CREATE SCHEMA [schema_name] AUTHORIZATION [user];

スキーマ削除

DROP SCHEMA [schema_name] CASCADE;

参考文献

https://www.dbonline.jp/postgresql/schema/index1.html
https://tech.pscsrv.co.jp/2021/08/02/%E3%80%90postgresql%E3%80%91postgresql%E3%81%AE%E3%82%B9%E3%82%AD%E3%83%BC%E3%83%9E%EF%BC%88schema%EF%BC%89%E3%81%AB%E3%81%A4%E3%81%84%E3%81%A6/

関連記事

PostgreSQL ~ 基礎知識編 ~
https://dk521123.hatenablog.com/entry/2014/03/08/000100
PostgreSQLのインデックスあれこれ
https://dk521123.hatenablog.com/entry/2021/08/15/000000