(转:http://www.cnblogs.com/yangy608/archive/2011/08/22/2148893.html)html
create user TEST identified by "TEST" --建立TEST用户session
default tablespace USERSide
temporary tablespace TEMPspa
profile DEFAULT;htm
grant connect,create view ,resource to TEST;blog
grant unlimited tablespace to TEST;get
--管理员受权it
grant create session to TEST;--授予TEST用户建立session的权限,即登录权限io
grant unlimited session to TEST;--授予TEST用户使用表空间的权限table
grant create table to TEST;--授予建立表的权限
grant drop table to TEST;--授予删除表的权限
grant insert table to TEST;--插入表的权限
grant update table to TEST;--修改表的权限
grant all to public;--这条比较重要,授予全部权限(all)给全部用户(public)
--oralce对权限管理比较严谨,普通用户之间也是默认不能互相访问的
grant select on tablename to TEST;--授予TEST用户查看指定表的权限
grant drop on tablename to TEST;--授予删除表的权限
grant insert on tablename to TEST;--授予插入的权限
grant update on tablename to TEST;--授予修改表的权限
grant insert(id) on tablename to TEST;
grant update(id) on tablename to TEST;--授予对指定表特定字段的插入和修改权限,注意,只能是insert和update
--撤销权限
基本语法同grant,关键字为revoke
--查看权限
select * from user_sys_privs;--查看当前用户全部权限
select * from user_tab_privs;--查看所用用户对表的权限
--操做表的用户的表
/*须要在表名前加上用户名,以下*/
--权限传递
即用户A将权限授予B,B能够将操做的权限再授予C,命令以下:
grant alert table on tablename to TEST with admin option;--关键字 with admin option
grant alert table on tablename to TEST with grant option;--关键字 with grant option效果和admin相似
--角色
角色即权限的集合,能够把一个角色授予给用户
create role myrole;--建立角色
grant create session to myrole;--将建立session的权限授予myrole
grant myrole to TEST;--授予TEST用户myrole的角色
drop role myrole;删除角色
/*可是有些权限是不能授予给角色的,好比unlimited tablespace和any关键字*/