<p>权限:</p><pre class="brush:bash;toolbar:false">  createsession   createtable   unlimitedtablespace   connect   resource   dba</pre><p>  例:</p><pre class="brush:bash;toolbar:false">  #sqlplus/nolog   SQL&gt;conn/assysdba;   SQL&gt;createuserusernameidentifiedbypassword   SQL&gt;grantdbatousername;   SQL&gt;connusername/password   SQL&gt;select*fromuser_sys_privs;</pre><p>  我们将从创建Oracle用户权限表开始谈起,然后讲解登陆等一般性动作,使大家对Oracle用户权限表有个深入的了解。</p><p>  一、创建</p><pre class="brush:sql;toolbar:false">  sys;//系统管理员,拥有最高权限   system;//本地管理员,次高权限   scott;//普通用户,密码默认为tiger,默认未解锁</pre><p>  二、登陆</p><pre class="brush:sql;toolbar:false">  sqlplus/assysdba;//登陆sys帐户   sqlplussysassysdba;//同上   sqlplusscott/tiger;//登陆普通用户scott</pre><p>  三、管理用户</p><pre class="brush:sql;toolbar:false">  createuserzhangsan;//在管理员帐户下,创建用户zhangsan   alertuserscottidentifiedbytiger;//修改密码</pre><p>  四,授予权限</p><p>  1、默认的普通用户scott默认未解锁,不能进行那个使用,新建的用户也没有任何权限,必须授予权限</p><pre class="brush:sql;toolbar:false">  grantcreatesessiontozhangsan;//授予zhangsan用户创建session的权限,即登陆权限   grantunlimitedtablespacetozhangsan;//授予zhangsan用户使用表空间的权限   grantcreatetabletozhangsan;//授予创建表的权限   grantedroptabletozhangsan;//授予删除表的权限   grantinserttabletozhangsan;//插入表的权限   grantupdatetabletozhangsan;//修改表的权限   grantalltopublic;//这条比较重要,授予所有权限(all)给所有用户(public)</pre><p>  2、oralce对权限管理比较严谨,普通用户之间也是默认不能互相访问的,需要互相授权</p><pre class="brush:sql;toolbar:false">  grantselectontablenametozhangsan;//授予zhangsan用户查看指定表的权限   grantdropontablenametozhangsan;//授予删除表的权限   grantinsertontablenametozhangsan;//授予插入的权限   grantupdateontablenametozhangsan;//授予修改表的权限   grantinsert(id)ontablenametozhangsan;   grantupdate(id)ontablenametozhangsan;//授予对指定表特定字段的插入和修改权限,注意,只能是insert和update   grantalertalltabletozhangsan;//授予zhangsan用户alert任意表的权限</pre><p>  五、撤销权限</p><p>  基本语法同grant,关键字为revoke</p><p>  六、查看权限</p><pre class="brush:sql;toolbar:false">  select*fromuser_sys_privs;//查看当前用户所有权限   select*fromuser_tab_privs;//查看所用用户对表的权限</pre><p>  七、操作表的用户的表</p><pre class="brush:sql;toolbar:false">     select*fromzhangsan.tablename</pre><p>  八、权限传递</p><p>  即用户A将权限授予B,B可以将操作的权限再授予C,命令如下:</p><pre class="brush:sql;toolbar:false">  grantalerttableontablenametozhangsanwithadminoption;//关键字withadminoption   grantalerttableontablenametozhangsanwithgrantoption;//关键字withgrantoption效果和admin类似</pre><p>  九、角色</p><p>  角色即权限的集合,可以把一个角色授予给用户</p><pre class="brush:sql;toolbar:false">  createrolemyrole;//创建角色   grantcreatesessiontomyrole;//将创建session的权限授予myrole   grantmyroletozhangsan;//授予zhangsan用户myrole的角色   droprolemyrole;删除角色</pre>
返回顶部 留言