常用命令:
启动数据库:postmaster -D/usr/local/pgsql/data > /usr/local/pgsql/pglog/log 2>&1 &
关闭数据库:source ~/.bash_profile pg_ctl stop
查看数据库是否启动: ps -ef|greppost
创建数据库: createdb mydb
删除数据库: dropdb mydb
进入数据库: psql mydb
退出数据库: \q
列出数据库表: \d
创建新表:
CREATE TABLE cities (
name varchar(80),
location point
);
向表中添加行:
INSERTINTO cities VALUES ('San Francisco', '(-194.0, 53.0)');
INSERTINTO products (product_no, name, price) VALUES (1, 'Cheese', DEFAULT);
查询:
SELECTselect_list FROM table_expression [sort_specification]
SELECT... FROM fdt WHERE c1 > 5
SELECTx, sum(y) FROM test1 GROUP BY x;
SELECTDISTINCT select_list ...
SELECTa FROM table1 ORDER BY b;