PostgreSQL8.1.3

1.起動/停止

>net start pgsql-8.1
PostgreSQL Database Server 8.1 サービスを開始します.
PostgreSQL Database Server 8.1 サービスは正常に開始されました。

>net stop pgsql-8.1
PostgreSQL Database Server 8.1 サービスを停止中です.
PostgreSQL Database Server 8.1 サービスは正常に停止されました。

2.対話型インタフェース

>psql -U postgres
Password for user postgres:
Welcome to psql 8.1.3, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help with psql commands
       \g or terminate with semicolon to execute query
       \q to quit

postgres=# \l
        List of databases
   Name    |  Owner   | Encoding
                                                                • -
postgres | postgres | EUC_JP template0 | postgres | EUC_JP template1 | postgres | EUC_JP (3 rows) postgres=# \q
2.1 psqlコマンド
postgres=# \?
2.2 SQLコマンド
postgres=# \h

3.データベースの作成/削除

3.1 専用コマンドの場合
>createdb -U postgres testdb
Password:
CREATE DATABASE

>dropdb -U postgres testdb
Password:
DROP DATABASE
3.2 対話的インタフェースの場合
>psql -U postgres
Password for user postgres:
Welcome to psql 8.1.3, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help with psql commands
       \g or terminate with semicolon to execute query
       \q to quit

postgres=# create database testdb;
CREATE DATABASE
postgres=# drop database testdb;
DROP DATABASE
postgres=# \q

4.データベースユーザの作成/パスワード変更/削除

4.1 専用コマンドの場合
>createuser -U postgres -P
Enter name of role to add: papa33
Enter password for new role:
Enter it again:
Shall the new role be a superuser? (y/n) y
Password:
CREATE ROLE

>dropuser -U postgres
Enter name of role to drop: papa33
Password:
DROP ROLE
4.2 対話的インタフェースの場合
>psql -U postgres template1
Password for user postgres:
Welcome to psql 8.1.3, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help with psql commands
       \g or terminate with semicolon to execute query
       \q to quit

template1=# CREATE USER papa33 WITH PASSWORD 'hoge' CREATEDB CREATEUSER;
CREATE ROLE
template1=# ALTER USER papa33 WITH PASSWORD 'fuga';
ALTER ROLE
template1=# DROP USER papa33;
DROP ROLE
template1=# \q