PostgreSQL事始め

PostgreSQLを使い始めたので、備忘録として残しておこう。

インストール

brew install postgresql

起動

brew services start postgresql

brew servicesでデーモンを管理できる。

pg_ctl -D {database directory} start

でも起動できる。

以下、デーモン起動後に行う

クラスターの作成

pg_ctl -D {database directory} init

または、

initdb {database directory}

設定

psql {database name}

データベースの一覧

psql -l

クラスターとは

(https://www.postgresql.org/docs/current/static/creating-cluster.html)より引用。

a database storage area on disk

a collection of databases that is managed by a single instance of a running database server