Profile是用户的配置文件,它是密码限制,资源限制的命名集合。利用profile 可以对数据库用户进行基本的资源管理,密码管理。
1 创建profile 的语法
create profile profile_test1 limit
failed_login_attempts 3
password_lock_time 1
password_life_time 90
password_reuse_time 90
sessions_per_user unlimited
cpu_per_session unlimited
cpu_per_call 1000
connect_time 30
logical_reads_per_session default
logical_reads_per_call 1000
composite_limit 6
private_sga 128k;
(1) 对数据库资源做限制
sessions_per_user 每个用户名所允许的并行会话数
cpu_per_session 一个会话一共可以使用的cpu时间,单位是百分之一秒
ccpu_per_call 一次sql调用(解析、执行和获取)允许使用的cpu时间
connect_time 限制会话连接时间,单位是分钟
idle_time 允许空闲会话的时间,单位是分钟
logical_reads_per_session 限制会话对数据块的读取,单位是块
logical_reads_per_call 限制sql调用对数据块的读取,单位是块
composite_limit 指定一个会话的总的资源消耗,以service units单位表示
private_sga 限制会话在sga中shared pool中私有空间的分配
(2) 对密码做限制
failed_login_attempts 帐户被锁定之前可以错误尝试的次数
password_life_time 密码可以被使用的天数,单位是天,默认值180天
password_reuse_time 密码可重用的间隔时间(结合password_reuse_max)
password_reuse_max 密码的最大改变次数(结合password_reuse_time)
password_lock_time 超过错误尝试次数后,用户被锁定的天数,默认1天
password_grace_time 当密码过期之后还有多少天可以使用原密码
password_verify_function 该字段允许将复杂的PL/SQL密码验证脚本做为参数传递到create
2 创建用户指定profile
create user test2 identified by 123456
default tablespace default_tablespace
temporary tablespace temp
profile profile_test1;
查询创建的profile 对于资源与密码使用策略
select *
from dba_profiles
where profile='PROFILE_TEST1';
grant create session to test2;
此时用户对于密码与资源使用限制会遵循profile_test1,我们可以测试一下,连着输错3次密码,用户被锁
3 修改用户对应的profile
alter user test1 profile profile_test1;
4 修改profile
alter profile profile_test1 limit
cpu_per_session 10000
sessions_per_user 10
failed_login_attempts 5
password_grace_time 5
password_lock_time 3;
5 删除profile
drop profile profile_test1 cascade;
删除profile文件之后,使用这个profile的用户将自动重新指定default profile配置文件。