grant create view on Oracle 11g

后端 未结 4 457
被撕碎了的回忆
被撕碎了的回忆 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 10:59

    To log-in as DBA (database administrator) you can use:

    sqlplus / as sysdba
    

    or

    sqlplus sys as sysdba
    
    0 讨论(0)
  • 2020-12-21 11:16

    step 1-conn ss/ss as sysdba;
    step 2- GRANT CREATE ANY VIEW TO Scott;
    step 3- conn scott/tiger
    step 4-create or replace view v as select *from emp;

    0 讨论(0)
  • 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
    
    0 讨论(0)
  • 2020-12-21 11:24

    As the error states - your privileges are insufficient to create view - you will have to ask database administrator to grant you this privilege. If you can log in as database administrator you will have to execute statement(I can't guarantee correctness, no oracle database at hand)

    GRANT CREATE ANY VIEW TO Scott;
    

    or

    GRANT CREATE VIEW TO Scott;
    
    0 讨论(0)
提交回复
热议问题