DROP SCHEMA
说明:
移除一个模式
语法:
DROP SCHEMA [ IF EXISTS ] name [, ...] [ CASCADE | RESTRICT ]
示例:
--从数据库中移除模式mystuff及其中 所包含的对象:
DROP SCHEMA mystuff CASCADE;
CREATE USER
说明:
定义一个新的数据库角色
语法:
CREATE USER name [ [ WITH ] option [ ... ] ]
这里 option 可以是:
SUPERUSER | NOSUPERUSER
| CREATEDB | NOCREATEDB
| CREATEROLE | NOCREATEROLE
| INHERIT | NOINHERIT
| LOGIN | NOLOGIN
| REPLICATION | NOREPLICATION
| BYPASSRLS | NOBYPASSRLS
| CONNECTION LIMIT connlimit
| [ ENCRYPTED ] PASSWORD 'password' | PASSWORD NULL
| VALID UNTIL 'timestamp'
| IN ROLE role_name [, ...]
| IN GROUP role_name [, ...]
| ROLE role_name [, ...]
| ADMIN role_name [, ...]
| USER role_name [, ...]
| SYSID uid
示例:
--创建一个超级用户,并赋予登录权限
CREATE USER user1 SUPERUSER PASSWORD '123456' LOGIN;
ALTER USER
说明:
更改一个数据库角色
语法:
ALTER USER role_specification [ WITH ] option [ ... ]
其中 option 可以是:
SUPERUSER | NOSUPERUSER
| CREATEDB | NOCREATEDB
| CREATEROLE | NOCREATEROLE
| INHERIT | NOINHERIT
| LOGIN | NOLOGIN
| REPLICATION | NOREPLICATION
| BYPASSRLS | NOBYPASSRLS
| CONNECTION LIMIT connlimit
| [ ENCRYPTED ] PASSWORD 'password' | PASSWORD NULL
| VALID UNTIL 'timestamp'
ALTER USER name RENAME TO new_name
ALTER USER { role_specification | ALL } [ IN DATABASE database_name ] SET configuration_parameter { TO | = } { value | DEFAULT }
ALTER USER { role_specification | ALL } [ IN DATABASE database_name ] SET configuration_parameter FROM CURRENT
ALTER USER { role_specification | ALL } [ IN DATABASE database_name ] RESET configuration_parameter
ALTER USER { role_specification | ALL } [ IN DATABASE database_name ] RESET ALL
其中 role_specification 可以是:
role_name
| CURRENT_USER
| SESSION_USER
示例:
--重命名用户
ALTER USER adb01 RENAME TO adb02;
DROP USER
说明:
移除一个数据库角色
语法:
DROP USER [ IF EXISTS ] name [, ...]
示例:
--移除用户adb01:
DROP USER IF EXISTS adb01;
CREATE ROLE
说明:
定义一个新的数据库角色
语法:
CREATE ROLE name [ [ WITH ] option [ ... ] ]
where option可以是:
SUPERUSER | NOSUPERUSER
| CREATEDB | NOCREATEDB
| CREATEROLE | NOCREATEROLE
| INHERIT | NOINHERIT
| LOGIN | NOLOGIN
| REPLICATION | NOREPLICATION
| BYPASSRLS | NOBYPASSRLS
| CONNECTION LIMIT connlimit
| [ ENCRYPTED ] PASSWORD 'password' | PASSWORD NULL
| VALID UNTIL 'timestamp'
| IN ROLE role_name [, ...]
| IN GROUP role_name [, ...]
| ROLE role_name [, ...]
| ADMIN role_name [, ...]
| USER role_name [, ...]
| SYSID uid
示例:
--创建一个能登录但是没有口令的角色:
CREATE ROLE jonathan LOGIN;
--创建一个有口令的角色:
CREATE USER davide WITH PASSWORD 'jw8s0F4';