| $ createuser (ユーザ名) |
| $ createuser hogehoge |
| Enter user's postgres ID or RETURN to use unix user ID: 1000 -> |
| (もしunix user IDと異る値を使う場合には数字を入力) |
| Is user "hogehoge" allowed to create databases (y/n) |
| (もしユーザにデータベースを作成する権利を与えるならy:通常y) |
| Is user "hogehoge" a superuser? (y/n) |
| (もしユーザにユーザを作成する権利を与えるのならy:通常n) |
| createuser: hogehoge was successfully added |
| (このメッセージが出たら正常にユーザは作成されたことを意味する) |
| $ createdb (データベース名) |
| $ createdb testdb |
| datname | | | datdba | | | encoding | | | datpath |
| --------- | + | ------ | + | -------- | + | -------- |
| template1 | | | 31 | | | 1 | | | template1 |
| testdb | | | 1000 | | | 1 | | | testdb |
| testdb => \i book.sql |
| CREATE TABLE book ( |
| bookname varchar(80), |
| keyword varchar(80), |
| date date |
| ); |
| testdb => INSERT INTO book VALUES ('PostgreSQL解説','コンピュータ','10/30/2002'); |
| testdb => INSERT INTO book VALUES ('確率過程入門','確率過程','4/25/2000'); |
| testdb => INSERT INTO book (bookname, date, keyword ) VALUES ('PostgreSQL解説','10/30/2002','コンピュータ'); |
| testdb => INSERT INTO book (bookname, keyword) VALUES ('確率過程入門','確率過程'); |
| testdb => SELECT * FROM book; | ||||
| bookname | | | keyword | | | date |
| -------------------------------- | + | --------------- | + | -------------- |
| PostgreSQL解説 | | | コンピュータ | | | 10-30-2002 |
| 確率過程入門 | | | 確率過程 | | | 4-25-2000 |
| testdb => UPDATE book SET bookname = 'PostgreSQL入門' WHERE date ='10/30/2002'; |
| testdb => GRANT ALL ON book TO 'www-data'; |
| testdb => DELETE FROM book WHERE bookname = 'PostgreSQL入門'; |
| testdb => DROP TABLE book; |
| pg_dump (データベース名) > dump.out |
| psql -e (データベース名) < dump.out |