Welcome 微信登录

首页 / 数据库 / MySQL / Oracle创建用户与权限操作

1.创建用户create userSQL>create user arthur identified by m123(m123是密码,必须是以字母开头)一般的普通用户是无权限用create user的可以切换用户然后创建#用system来创建用户arthurSQL>conn system/密码SQL>create user arthur identified by m123------------------------------------------------------------------------2.注意上面创建了arthur,但是它只是个孤零零的用户,没有任何权限,所以下面的链接语句也不会执行成功SQL>conn arthur/m123,//没有权限,运行不成功3.为了获得权限,用grant,收回一个权限revoke可以让system来赋给arthur 权限#首先登陆systemSQL>conn system/密码SQL>grant connect to arhtur 回车//system把connect权限给予arthur授权成功然后执行链接SQL>conn arthur/m123就成功了--------------------------------------------------------------------------4.让用户arthur有权限建表,如果不付权限的话,arthur用户是不可以创建表的SQL>conn system/密码SQL>grant resource to arthur授权成功SQL>conn arthur/m123SQL>create table table_name--------------------------------------------------------------------------5.希望arthur用户可以查询scott用户的emp表授权者是:scott(因为emp是里面scott的表),SQL>conn scott/密码SQL>grant select on emp to arthur授权成功下面如果arthur想查询scott表emp可以用下面的语句(emp是表)先登录SQL>conn arthur/m123SQL>select * from emp;//此句错误SQL>select * from scott.emp;说明此时arthur对emp只有查询权限--------------------------------------------------------------------------6.如果arthur用户想更新scott的emp,可以用下面的授权SQL>conn scott/密码SQL>grant update on emp to arthur授权成功说明此时arthur对emp只有更改权限--------------------------------------------------------------------------7.如果arthur用户可以修改/删除/查询/添加scott的emp表可以用下面的语句SQL>conn scott/密码SQL>grant all on emp to arthur授权成功收回权限(scott收回arthur对emp表的查询权限)SQL>conn scott/密码SQL> revoke select on emp from arthur--------------------------------------------------------------------------8"权限的传递,scott给arthur赋权限的同时,也允许arthur继续把权限传递下去当然arthur传递的权限不能超越scott所受的权限scott>--arthur>----somebody如果是对象权限,就加入 with grant optionSQL> conn scott/密码已连接SQL>grant select on emp to arthur with grant option下面arthur把对emp的选择权限受权给另一个用户 tom#先登录SQL>conn arthur/m123SQL>grant select on emp to tom //此种写法错误,arthur里面没有emp表SQL>grant select on scott.emp to tom注意:当scott把arthur的权限select回收revoke时,tom对emp的select权限也是被回收了如果是系统权限system 赋权给arthurOracle数据库归档模式设置Oracle Database 11g R2 在Oracle Linux 6.3和Ubuntu 12.04的安装相关资讯      Oracle基础 
  • Oracle基础介绍及常用相关SQL*PLUS  (03月11日)
  • Oracle 角色的两个特性和误区  (09/04/2012 05:56:16)
  • Oracle rac11.2.0.3.0的vip在重启  (09/02/2012 10:00:39)
  • Oracle中删除用户遇到的问题  (09/08/2012 20:01:42)
  • IMP-00008: unrecognized   (09/02/2012 10:03:25)
  • 在Oracle数据库上设置限制ip地址访  (09/02/2012 09:59:55)
本文评论 查看全部评论 (0)
表情: 姓名: 字数