您当前的位置: 首页 >  oracle

郭梧悠

暂无认证

  • 4浏览

    0关注

    402博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

oracle创建用户与权限操作(oracle学习笔记一)

郭梧悠 发布时间:2012-07-23 16:10:17 ,浏览量:4

1.创建用户create user SQL>create user arthur identified by m123 (m123是密码,必须是以字母开头) 一般的普通用户是无权限用create user的 可以切换用户然后创建 #用system来创建用户arthur SQL>conn system/密码 SQL>create user arthur identified by m123 ------------------------------------------------------------------------ 2.注意上面创建了arthur,但是它只是个孤零零的用户, 没有任何权限,所以下面的 链接语句也不会执行成功 SQL>conn arthur/m123,//没有权限,运行不成功 -------------------------------------------------------------------------- 3.为了获得权限,用grant,收回一个权限revoke 可以让system来赋给arthur 权限 #首先登陆system SQL>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/m123 SQL>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/m123 SQL>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 option SQL> conn scott/密码 已连接 SQL>grant select on emp to arthur with grant option 下面arthur把对emp的选择权限受权给另一个用户 tom #先登录 SQL>conn arthur/m123 SQL>grant select on emp to tom //此种写法错误,arthur里面没有emp表 SQL>grant select on scott.emp to tom 注意:当scott把arthur的权限select回收revoke时,tom对emp的select权限也是被回收了 如果是系统权限 system 赋权给arthur  grant conn to arthur with admin option --------------------------------------------------------------------------
关注
打赏
1663674776
查看更多评论
立即登录/注册

微信扫码登录

0.0354s