您的位置:首页 > 数据库 > Oracle

Oracle创建用户及权限设置

2015-08-06 21:24 585 查看

Oracle创建用户及权限的设置

权限:
  create session
  create table
  unlimited tablespace
  connect
  resource
  dba
  例:
  #sqlplus /nolog
  SQL> conn / as sysdba;
  SQL>create user username identified by password //创建用户并赋予密码
  SQL> grant dba to username;
  SQL> conn username/password
  SQL> select * from user_sys_privs;
  我们将从创建Oracle用户权限表开始谈起,然后讲解登陆等一般性动作,使大家对Oracle用户权限表有个深入的了解。
  一、创建
  sys;//系统管理员,拥有最高权限
  system;//本地管理员,次高权限
  scott;//普通用户,密码默认为tiger,默认未解锁
  二、登陆
  sqlplus / as sysdba;//登陆sys帐户
  sqlplus sys as sysdba;//同上
  sqlplus scott/tiger;//登陆普通用户scott
  三、管理用户
  create user vashon;//在管理员帐户下,创建用户vashon
  alert user scott identified by tiger;//修改密码
  四,授予权限
  1、默认的普通用户scott默认未解锁,不能进行那个使用,新建的用户也没有任何权限,必须授予权限
  
  grant create session to
vashon;//授予vashon用户创建session的权限,即登陆权限
  grant unlimited tablespace to
vashon;//授予vashon用户使用表空间的权限
  grant create table to
vashon;//授予创建表的权限
  grant drop table to
vashon;//授予删除表的权限
grant drop any table tovashon;// 注意:即使以上是以管理员登陆并授权但还会提示权限不够,需要指定
"any"
  grant insert table to
vashon;//插入表的权限
grant insert any table to vashon;//注意:即使以上是以管理员登陆并授权但还会提示权限不够,需要指定
"any"
  grant update table to
vashon;//修改表的权限
grant update any table to vashon;//注意:即使以上是以管理员登陆并授权但还会提示权限不够,需要指定
"any"

  grant all to public;//这条比较重要,授予所有权限(all)给所有用户(public)
  2、oralce对权限管理比较严谨,普通用户之间也是默认不能互相访问的,需要互相授权
  
  grant select on tablename to
vashon;//授予vashon用户查看指定表的权限
grant select any table to
vashon;// 授予用户查看本用户下所有表的权限
  grant drop on tablename to
vashon;//授予删除表的权限
  grant insert on tablename to
vashon;//授予插入的权限
  grant update on tablename to
vashon;//授予修改表的权限
  grant insert(id) on tablename tovashon;
  grant update(id) on tablename tovashon;//授予对指定表特定字段的插入和修改权限,注意,只能是insert和update
  grant alert all table to
vashon;//授予vashon用户alert任意表的权限
  五、撤销权限
  基本语法同grant,关键字为revoke
  六、查看权限
  select * from user_sys_privs;//查看当前用户所有权限
  select * from user_tab_privs;//查看所用用户对表的权限
  七、操作表的用户的表
  
  select * from
vashon.tablename
  八、权限传递
  即用户A将权限授予B,B可以将操作的权限再授予C,命令如下:
  grant alert table on tablename tovashon with admin option;//关键字 with admin option
  grant alert table on tablename tovashon with grant option;//关键字 with grant option效果和admin类似
  九、角色
  角色即权限的集合,可以把一个角色授予给用户
  create role myrole;//创建角色
  grant create session to myrole;//将创建session的权限授予myrole
  grant myrole to
vashon;//授予vashon用户myrole的角色
  drop role myrole;删除角色
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: