jieshiyeskey@gmail.com
1.创建用户并附权限及设置密码
postgres=# create role markgeng password 'Jieshi11gR2' login superuser createdb createrole;
CREATE ROLE
postgres=# \dg+
-----------+------------------------------------------------+-----------+-------------
2.创建表空间
postgres=# create tablespace tsp_users owner markgeng location '/Library/Postgresql/9.2/data/tsp_users';
postgres=# \db+
------------+----------+----------------------------------------+-------------------+-------------
3.创建数据库
postgres=# create database orcl owner=markgeng tablespace=tsp_users;
CREATE DATABASE
postgres=# \l+
---------------+----------+----------+---------+-------+-----------------------+---------+------------+--------------------------------------------
4.创建schema
postgres=# \c orcl markgeng
Password for user markgeng:
You are now connected to database "orcl" as user "markgeng".
orcl=# create schema authorization markgeng;
CREATE SCHEMA
orcl=# \dn+
----------+----------+----------------------+------------------------
(2 rows)
5.创建表
orcl=# create table t1(id int);
CREATE TABLE
orcl=# \dt+
----------+------+-------+----------+---------+-------------
(1 row)
orcl=# \d t1
--------+---------+-----------
orcl=# insert into t1 values(1);
INSERT 0 1
orcl=# select * from t1;
----
(1 row)