一 、oracle 授权新用户视图查询权限

create user veh_cx identified by "nccd.com";--创建用户

create or replace view  veh_cx_view as select  xh,hm,sj,gxrq from veh where glbm  like '900%' ;--创建视图

grant connect to veh_cx ;--授权连接权限

grant select on veh_cx_view to veh_cx;--授权veh_cx_view视图的查询权限给到veh_cx用户

 

 

二、授权 

grant connect to veh_cx;--授权connect 角色给veh_cx用户,允许create session权限,用于连接和登录;

grant select on veh_cx_view to veh_cx;--授权veh_cx_view 视图的select权限给用户 veh_cx进行查询操作; 

三、回收权限 

revoke connect from  veh_cx;--从veh_cx用户收回connect连接权限;

revoke select on veh_cx_view  from veh_cx--从veh_cx用户收回在veh_cx_view视图的查询权限;

四、查询权限

select * from dba_sys_privs where grantee='veh_cx'; --查询该用户具有哪些权限

select * from role_tab_privs where role='veh_cx';--查询该用户拥有哪些角色和权限

五、关于角色

     当需要一组固定权限较多时,可新建角色,将权限赋予角色,再将角色授权给用户;

create role cx_admin ;--创建角色

drop role cx_admin ;--删除角色

grant select on veh_cx_view to cx_admin ;将视图查询权限赋予cx_admin角色

revoke select on veh_cx_view from cx_admin;将视图查询权限从角色cx_admin中收回

grant cx_admin to veh_cx;--将cx_admin角色赋予用户;

 

 

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐