无法创建视图 - 权限不足

Unable to create view - insufficient privileges

我无法创建视图 - 我获得的权限不足。 工作流程 -> 创建角色 -> 将创建视图授予角色 -> 创建用户 -> 向用户添加角色 -> 尝试创建视图,但出现错误。任何帮助将不胜感激

创建了角色

CREATE ROLE enrolment;

授予角色以下权限 - base table hr.students

GRANT insert, select, update
ON hr.students
TO enrolment;

还授予角色创建视图权限

GRANT create view 
TO enrolment;

创建了以下用户

CREATE USER enrol1
IDENTIFIED BY pw4321;

已将角色授予帐户

GRANT enrolment
TO enrol1;

当我尝试在基础 table hr.students 上创建以下视图时,我被告知我没有足够的权限。我可以 运行 select 基于 table 的语句。

CREATE OR REPLACE VIEW vu_student_name
 AS SELECT student_id, lastname
    FROM hr.students;

From the documentation:

The owner of the schema containing the view must have the privileges necessary to either select, insert, update, or delete rows from all the tables or views on which the view is based. The owner must be granted these privileges directly, rather than through a role.

您只有通过该角色授予的基本 table 权限。他们需要直接授予 enrol1.