【AntDB数据库 SQL语法专栏】——DDL语句(5)

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';
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值