SQL 在 Oracle 11g 上授予创建视图
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20595701/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
grant create view on Oracle 11g
提问by David Lacombe
I use SQL*Plus for school and I use the username Scott. I cannot create views because it says:
我在学校使用 SQL*Plus,我使用用户名 Scott。我无法创建视图,因为它说:
ORA-01031: insufficient privileges;
I've searched and searched, but nothing seems to get it right. Any help?
我搜索了又搜索,但似乎没有什么是正确的。有什么帮助吗?
回答by mkubacki
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)
由于错误状态 - 您的权限不足以创建视图 - 您必须要求数据库管理员授予您此权限。如果您可以以数据库管理员身份登录,则必须执行语句(我不能保证正确性,手头没有oracle数据库)
GRANT CREATE ANY VIEW TO Scott;
or
或者
GRANT CREATE VIEW TO Scott;
回答by Lalit Kumar B
You need to GRANTthe CREATE VIEWprivilege to the USERwhich is creating the view.
您需要GRANT的CREATE 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 revokethe privilege, you will recieve ORA-01031: insufficient privileges:
如果我撤销权限,您将收到ORA-01031:权限不足:
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
回答by naseem ahmad
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;
步骤 1-conn ss/ss 作为 sysdba;
第 2 步 - 向 Scott 授予创建任何视图的权限;
第 3 步- conn scott/tiger
第 4 步-创建或替换视图 v 为 select *from emp;
回答by Jan Vitásek
To log-in as DBA (database administrator) you can use:
要以 DBA(数据库管理员)身份登录,您可以使用:
sqlplus / as sysdba
or
或者
sqlplus sys as sysdba