CREATE ANY VIEW SQL
The name of the privilege is actually CREATE ANY VIEW
, not CREATE ANY VIEW TO
.
First of all, this does not create a view. A privilege is a right to perform a specific type of operation (or a group of them), to access an object (or a group of them), and so on. You give (grant) a privilege to a user (grantee) with a command like :
GRANT <privilege> TO <user>
The CREATE ANY VIEW
privilege allows the grantee to create a view in any schema. By opposition, the CREATE VIEW
priviliege allows a user to create views only in its own schema.
From the Oracle docs :
To create a view in your own schema, you must have the
CREATE VIEW
system privilege. To create a view in another user's schema, you must have theCREATE ANY VIEW
system privilege
grant create view using system view with dba privilage in oracle
Most likely, the issue is that your access to dba_users
comes via a role. If you want to create a view that references dba_users
(or if you want to creates a definer's rights stored procedure that references dba_users
), you would need to have privileges granted to your user directly not via a role. Assuming you want to be able to reference all the data dictionary tables in views and stored procedures, you probably want to ask your DBA to grant you the SELECT ANY DICTIONARY
privilege directly not via a role.
Permission to create VIEW for table with SELECT right
Privileges Required to Create Views
To create a view, you must meet the following requirements:
You must have been granted the CREATE VIEW (to create a view in your schema) or CREATE ANY VIEW (to create a view in another user's schema) system privilege, either explicitly or through a role.
You must have been explicitly granted the SELECT, INSERT, UPDATE, or DELETE object privileges on all base objects underlying the view or the SELECT ANY TABLE, INSERT ANY TABLE, UPDATE ANY TABLE, or DELETE ANY TABLE system privileges. You may not have obtained these privileges through roles.
Additionally, in order to grant other users access to your view, you must have received object privilege(s) to the base objects with the GRANT OPTION option or appropriate system privileges with the ADMIN OPTION option. If you have not, grantees cannot access your view."
Unable to create view - insufficient privileges
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.
You only have the base table privileges granted through the role. They need to be granted directly to enrol1
.
Grant create any trigger vs grant create trigger
In most cases, the trigger owner is also the owner of the table (or view) on which the trigger is based. In those cases, the table owner, with CREATE TRIGGER can create create triggers on their own table.
CREATE ANY TRIGGER allows the user to create a trigger owned by any user on any table. It is a big security hole because they can create a trigger owned by a privileged user on a table that they own or can insert into. Because they can insert into that table, they can force the trigger to execute and the trigger executes with the privileges of the trigger owner. The effect is that a user with CREATE ANY TRIGGER privilege can create and execute code as a privileged user (similar to having CREATE ANY PROCEDURE plus EXECUTE ANY PROCEDURE).
Limit to as few as people as possible and audit appropriately.
Grant Resource to user to create table
You will need to reconnect with your user once it is given resource
grant(from sys user) as your current session
can not identify the newly given grant (resource).
Cheers!!
Related Topics
Search If Number Is Contained Within an Expression Like: 1-3,5,10-15,20
Bigquery Update Nested Array Field
SQL Server: Order by Parameters in In Statement
Insert Inserted Id to Another Table
Passing Multiple Values in Single Parameter
How to Merge Two or More Rows Based on Their Foreign Key
Transposing SQLite Rows and Columns with Average Per Hour
Oracle Shutdown Error Ora-01033
SQL Server Cte Parent Child Recursive
Displaying Zero Valued Months with SQL
Trying to Split One Column to Multiple Columns Using Snowflake SQL
How to Extract Values from Column and Update Result in Another Column
How to Convert "2019-11-02T20:18:00Z" to Timestamp in Hql
Ordered Count of Consecutive Repeats/Duplicates
How to Select First N Rows from a Table in T-Sql
SQL Query Where Date = Today Minus 7 Days
"An Item with the Same Key Has Already Been Added" Error on Ssrs When Trying to Set Dataset