在 Oracle 中创建具有所有权限的用户
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22386976/
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
Create a user with all privileges in Oracle
提问by Renaud is Not Bill Gates
I was googling about how to create a user and grant all privileges to him.
我在谷歌上搜索如何创建用户并将所有权限授予他。
I found these two methods :
我找到了这两种方法:
The first method :
第一种方法:
create user userName identified by password;
grant connect to userName;
grant all privileges to userName;
The second method :
第二种方法:
grant connect , resource to userName identified by password;
So what's the difference between those two methods ?
那么这两种方法有什么区别呢?
回答by Christian13467
There are 2 differences:
有2个区别:
2 methods creating a user and granting some privileges to him
2 创建用户并授予他一些权限的方法
create user userName identified by password;
grant connect to userName;
and
和
grant connect to userName identified by password;
do exactly the same. It creates a user and grants him the connect role.
完全一样。它创建一个用户并授予他连接角色。
different outcome
不同的结果
resource is a role in oracle, which gives you the right to create objects (tables, procedures, some more but no views!). ALL PRIVILEGES grants a lot more of system privileges.
资源是oracle 中的一个角色,它赋予您创建对象(表、过程、更多但没有视图!)的权利。ALL PRIVILEGES 授予更多的系统权限。
To grant a user all privilegesrun you first snippet or
要授予用户所有权限,请运行您的第一个片段或
grant all privileges to userName identified by password;
回答by Amarendra
My issue was, i am unable to create a view with my "scott" user in oracle 11g edition. So here is my solution for this
我的问题是,我无法在 oracle 11g 版本中使用我的“scott”用户创建视图。所以这是我的解决方案
Error in my case
我的情况错误
SQL>create view v1 as select * from books where id=10;
查询>create view v1 as select * from books where id=10;
insufficient privileges.
权限不足。
Solution
解决方案
1)open your cmd and change your directory to where you install your oracle database. in my case i was downloaded in E drive so my location is E:\app\B_Amar\product\11.2.0\dbhome_1\BIN> after reaching in the position you have to type sqlplus sys as sysdba
1)打开你的cmd并将目录更改为安装oracle数据库的位置。在我的情况下,我是在 E 驱动器中下载的,所以我的位置是 E:\app\B_Amar\product\11.2.0\dbhome_1\BIN> 到达位置后,您必须键入 sqlplus sys as sysdba
E:\app\B_Amar\product\11.2.0\dbhome_1\BIN>sqlplus sys as sysdba
E:\app\B_Amar\product\11.2.0\dbhome_1\BIN>sqlplus sys as sysdba
2) Enter password: here you have to type that password that you give at the time of installation of oracle software.
2) 输入密码:在此输入您在安装oracle 软件时提供的密码。
3) Here in this step if you want create a new user then you can create otherwise give all the privileges to existing user.
3)在此步骤中,如果您想创建一个新用户,那么您可以创建否则将所有权限授予现有用户。
for creating new user
用于创建新用户
SQL> create user abc identified by xyz;
查询> create user abc identified by xyz;
here abc is user and xyz is password.
这里 abc 是用户,xyz 是密码。
giving all the privileges to abc user
将所有权限授予 abc 用户
SQL> grant all privileges to abc;
查询> grant all privileges to abc;
grant succeeded.
if you are seen this message then all the privileges are giving to the abc user.
如果您看到此消息,则所有权限都将授予 abc 用户。
4) Now exit from cmd, go to your SQL PLUS and connect to the user i.e enter your username & password.Now you can happily create view.
4)现在退出cmd,进入你的SQL PLUS并连接到用户,即输入你的用户名和密码。现在你可以愉快地创建视图了。
In My case
就我而言
in cmd E:\app\B_Amar\product\11.2.0\dbhome_1\BIN>sqlplus sys as sysdba
在 cmd 中 E:\app\B_Amar\product\11.2.0\dbhome_1\BIN>sqlplus sys as sysdba
SQL> grant all privileges to SCOTT;
查询> grant all privileges to SCOTT;
grant succeeded.
Now I can create views.
现在我可以创建视图。