grant create view on Oracle 11g

后端 未结 4 547
被撕碎了的回忆
被撕碎了的回忆 2020-12-21 10:43

I use SQL*Plus for school and I use the username Scott. I cannot create views because it says:

ORA-01031: insufficient privileges;

I\'ve se

4条回答
  •  佛祖请我去吃肉
    2020-12-21 11:20

    You need to GRANT the CREATE VIEW privilege to the USER which is creating the view.

    For example, I create a new user to let it create a session, a table and a view:

    SQL> create user test identified by test;
    
    User created.
    
    SQL> grant create session, create table, create view to test;
    
    Grant succeeded.
    
    SQL> conn test/test@pdborcl;
    Connected.
    SQL> Create Table advanced
      2   (Id  varchar(15),
      3   Name varchar(20),
      4   Dept  varchar(15),
      5   Cgpa  float,
      6   Birth_date date,
      7   Mob_no  int,
      8   Dist varchar(20),
      9   Salary  number(8));
    
    Table created.
    
    SQL> Create View advanced_data as
      2  (
      3  select name,dept,dist,salary from advanced
      4  );
    
    View created.
    

    If I revoke the privilege, you will recieve ORA-01031: insufficient privileges:

    SQL> revoke create view from test;
    
    Revoke succeeded.
    
    SQL> conn test/test@pdborcl;
    Connected.
    SQL> Create or replace View advanced_data as
      2  (
      3  select name,dept,dist,salary from advanced
      4  );
    Create or replace View advanced_data as
                           *
    ERROR at line 1:
    ORA-01031: insufficient privileges
    

提交回复
热议问题