创建角色

创建角色 “创建新的数据库角色

句法

创建角色 [schema.]name

描述

A ROLE is an entity that can own database objects and be assigned database privileges. Any user can create a ROLE. Use 下降角色 to drop a ROLE. Use 授予 and 撤销 to assign and remove privileges from roles. (See 下降角色, 授予, 撤销.) The user granting privileges on database objects to a ROLE must own both the ROLE and that database object for which they are granting privileges. It is recommended that you create roles, assign privileges to those roles, and then assign those roles to users, rather than assigning privileges directly to users. Users can assigned any number of roles.

参数

schema

Name of the schema in which the role will be created. The default is the current schema as defined by the 使用 command. If schema is provided, and the schema does not exist, it will be created.

name

Name (optionally schema-qualified) of the new role. If the schema does not exist it will be created. Roles cannot be created in the SYSTEM schema. This schema is reserved for database metadata.

例子

Create a ROLE. Assign 选择 on a table to the ROLE. Assign the ROLE to a 使用R.

创建角色 account_manager;
CREATE TABLE accounts_payable (id INTEGER, account_no STRING, amount NUMBER);
GRANT SELECT ON accounts_payable TO ROLE account_manager;

CREATE USER payroll_clerk password 'jd&dtk9';
GRANT account_manager TO payroll_clerk;