具有相同身份认证的
用户
角色
权限
角色的分类:
系统预定义角色 33个左右 基本用不到
用户自定义角色
查看当前数据库预定义角色
select * from DBA_ROLES;
用户自定义角色:
创建角色:
create role 角色名称 [not identified] [ identified by 密码]
[not identified] [ identified by 密码] 需不需要密码
eg:
create role high_tiger_role;
create role mid_tiger_role identified by midrole;
create role low_tiger_role identified by lowrole;
权限授予:
grant connect,create table,... to high_tiger_role;
grant select,update ,... on scott.emp to high_tiger_role;
角色不可以自己给自己授权 即不可以循环授权
修改角色
alter role 角色名称 [not identified] [ identified by 密码]
为 high_tiger_role 添加口令 取消mid_tiger_role 的
alter role high_tiger_role identified by 密码
取消密码
alter role mid_tiger_role not identified
角色创建者 自动具有对于角色的修改权限
其他 修改角色必须具有 alter any role 系统权限 以及 with admin option
角色的生效与失效
set role [角色名称[identified by 密码] ] | [ALL[EXCEPT 角色] ] | [NONE];
eg 所有角色失效:
set role none;
set role high_tiger_role identified by 密码 (角色之间可以用逗号分隔);
eg 除了 low_tiger_role 都生效
set role all except low_tiger_role;
删除角色:
drop role 角色名
利用角色进行授权管理
给用户或者角色授予角色
grant 角色 to 用户列表 角色列表
eg:
grant connect, high_tiger_role to user1;
从用户或者角色收回角色
revoke 角色列表 from 角色列表 用户列表;
用户角色的激活或者屏蔽
alter user 用户名 default role [角色名称] | [ALL[EXCEPT 角色] ] | [NONE];
查询角色信息:
select * from
dba_roles
dba_role_privs
user_role_privs
role_role_privs
概要文件
概要文件是数据库和系统资源的限制的集合 是oracle 数据库安全策略的重要组成部分。
每一个数据库都有一个概要文件 通常DBA 将用户分为几种类型,
每一种类型对应一个概要文件 然后将概要文件 分配给用户。
概要文件的限制类型
CPU使用时间
每个用户的并发会话数
用户连接数据库的时间
用户连接数据库的空闲时间
私有SQL区
创建概要文件:
create profile 概要文件名称 limit 资源参数|口令参数;
eg 创建一个名为pwd_profile 的概要文件 作用是 用户四次连续登陆失败 则锁定该账号 十天之后自动解锁
create profile pwd_profile limit failed_login_attempts 4 password_lock_time 10;
eg 创建一个名为 res_profile 的概要文件 要求每一个用户最多可以创建4个并发会话
每一个会话持续时间最长是 60 分钟 如果会话在连续20分钟内的空闲 则会话结束 每一个会话的私有sql区为100kb
每一个 sql语句的cpu占用时间时间总量不超过 10 秒
create profile res_profile limit session pre_user 4 connect_time 60 idle 20 private_sga 100K cpu_pre_call 10;
创建用户的时候指定概要文件
create user user1 identified by user1 profile res_profile;
重新分配概要文件
alter user user1 profile pwd_proflie
修改概要文件
alter profile 概要文件名字 limit 资源参数口令
eg:
修改 pwd_profile 将用户口令的有效时间修改为10天
alter pwd_profile limit password_limit_time 10
删除概要文件
drop profile 概要文件名字 cascade
查询概要文件
user_password_limits
user_resource_limits
dba_profiles