您好,登录后才能下订单哦!
创建用户并赋予该用户授权权限。
create user ken identified by ken;
授予权限并附带admin option
grant create session, create table to ken with admin option;
授予权限,不带with admin option
grant create view to ken;
新建tom用户
create user tom identified by tom;
使用ken用户登录后对tom授权, 语句执行成功
grant create session, create table to tom; Grant succeeded. 对tom授权,语句执行失败 grant create view to tom; grant create view to tom * ERROR at line 1: ORA-01031: insufficient privileges
note 注意,回收权限不是级联的。
从ken回收登录权限
revoke create session from ken;
此时tom依然可以登录,但Ken无法登录了
ERROR: ORA-01045: user KEN lacks CREATE SESSION privilege; logon denied
select distinct privilege from dba_tab_privs;
select grantor, owner, table_name, privilege from dba_tab_privs where grantee = 'TOM';
grant select on t to tom
grant all on emp to monkey;
grant update on emp(sal) to monkey
grant execute on dbms_transaction to ken;
grant index on scott.emp to blake;
revoke select on emp from blake
note 回收Object Privilege 会导致级联回收。
角色Role,定义一组权限。
select * from role_sys_privs where role='角色名'
select * from role_sys_privs where role='CONNECT';
select * from role_sys_privs where role='RESOURCE';
dba角色具有所有的系统权限,及with admin option选项,默认的dba用户为sys和system,它们可以将任何系统权限授予其他用户。但是要注意的是dba角色不具备sysdba和sysoper的特权(启动和关闭数据库)
note 一般而言,创建用户后,给与connect角色和resource就够了。
create role 角色名 not identified;
建立角色(数据库验证)
create role 角色名 identified by 密码;
grant create session to 角色名 with admin option grant select on scott.emp to 角色名; grant insert, update, delete on scott.emp to 角色名;
grant 角色名 to blake with admin option;
select * from dba_roles;
select privilege, admin_option from role_sys_privs where role='角色名';
select granted_role, default_role from dba_role_privs where grantee = '用户名';
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。