- # yum install readline-devel 未安装readline-devel会出现readline library not found错误 # wget # tar jxvf postgresql-9.1.2.tar.bz2 -C ../software/ # ./configure --prefix=/home/xuhh/pgsql912 --with-perl --with-python # gmake # gmake install # mkdir /home/xuhh/pgsql912/data # adduser postgres # chown -R postgres.postgres /home/xuhh/pgsql912 # chown postgres.postgres /home/xuhh/pgsql912/data # su - postgres $ /home/xuhh/pgsql912/bin/initdb -D /home/xuhh/pgsql912/data //初始化数据 $ /home/xuhh/pgsql912/bin/postgres -D /home/xuhh/pgsql912/data > /tmp/pg-logfile 2>&1 & //启动数据库
- $ /home/xuhh/pgsql912/bin/createdb test //创建数据库 $ /home/xuhh/pgsql912/bin/psql -d test //连接数据库 test=# CREATE TABLE test (id serial, name varchar(32)); test=# insert into test values(1,'abc'); test=# insert into test values('2','bbb'); test=# \dp+ //查看表空间 Access privileges Schema | Name | Type | Access privileges | Column access privileges --------+-------------+----------+-------------------+-------------------------- public | test | table | | public | test_id_seq | sequence | | (2 rows) test=# \dt+ //查看表 List of relations Schema | Name | Type | Owner | Size | Description --------+------+-------+----------+------------+------------- public | test | table | postgres | 8192 bytes | (1 row)
- test=# create tablespace xxoo location '/tmp/'; //创建表空间
- test=# select * from pg_tablespace; //查看表空间 spcname | spcowner | spclocation | spcacl | spcoptions ------------+----------+-------------+--------+------------ pg_default | 10 | | | pg_global | 10 | | | xxoo | 10 | /tmp/xxoo | | (3 rows)
- test=# alter tablespace xxoo rename to ttlsa; //更改表空间名 ALTER TABLESPACE test=# select * from pg_tablespace; spcname | spcowner | spclocation | spcacl | spcoptions ------------+----------+-------------+--------+------------ pg_default | 10 | | | pg_global | 10 | | | ttlsa | 10 | /tmp/xxoo | | (3 rows)