PostgreSQLのデータベースを、操作するコマンドです。
データベースの一覧を見る
データベースの一覧を見る方法です。
構文
l
使用例
postgres=# l List of databases Name | Owner | Encoding -----------+----------+---------- postgres | postgres | UTF8 sasuke | postgres | UTF8 sasuke2 | postgres | UTF8 template0 | postgres | UTF8 template1 | postgres | UTF8 test1 | postgres | UTF8 (6 rows)
データベースの作成
データベースの作成方法です。
構文
CREATE DATABASE データベース名;
文字コードを指定して、データベースを作成することも出来ます。
構文
CREATE DATABASE データベース名 ENCODING '文字コード';
使用例
postgres=# CREATE DATABASE sasuke; CREATE DATABASE postgres=# CREATE DATABASE sasuke2 ENCODING 'utf8'; CREATE DATABASE //一覧で確認 postgres=# l List of databases Name | Owner | Encoding -----------+----------+---------- postgres | postgres | UTF8 sasuke | postgres | UTF8 sasuke2 | postgres | UTF8 template0 | postgres | UTF8 template1 | postgres | UTF8 test1 | postgres | UTF8 (6 rows)
データベースの削除
データベースの削除する方法です。
構文
DROP DATABASE データベース名;
使用例
postgres=# DROP DATABASE sasuke; DROP DATABASE 一覧で確認する postgres=# l List of databases Name | Owner | Encoding -----------+----------+---------- postgres | postgres | UTF8 sasuke2 | postgres | UTF8 template0 | postgres | UTF8 template1 | postgres | UTF8 test1 | postgres | UTF8 (5 rows)