Oracle recommends that you use the Database Resource Manager rather than this SQL statement to establish resource limits. The Database Resource Manager offers a more flexible means of managing and tracking resource use. For more information on the Database Resource Manager, refer to Oracle Database Administrator's Guide.
Purpose
Use the CREATE PROFILE statement to create a profile, which is a set of limits on database resources. If you assign the profile to a user, then that user cannot exceed these limits.
Oracle系统中的profile可以用来对用户所能使用的数据库资源进行限制,使用Create Profile命令创建一个Profile,用它来实现对数据库资源的限制使用,如果把该profile分配给用户,则该用户所能使用的数据库资源都在该profile的限制之内。
Prerequisites
To create a profile, you must have the CREATE PROFILE system privilege.
To specify resource limits for a user, you must:
(1). Enable resource limits dynamically with the ALTER SYSTEM statement or with the initialization parameter RESOURCE_LIMIT. This parameter does not apply to password resources. Password resources are always enabled.
(2). Create a profile that defines the limits using the CREATE PROFILE statement
(3). Assign the profile to the user using the CREATE USER or ALTER USER statement
为用户指定资源限制,必须:
1.动态地使用alter system或使用初始化参数resource_limit使资源限制生效。该改变对密码资源无效,密码资源总是可用。
SQL> show parameter resource_limit
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
resource_limit boolean FALSE
SQL> alter system set resource_limit=true;
System altered.
SQL> show parameter resource_limit
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
resource_limit boolean TRUE
SQL>
CONNECT_TIMESpecify the total elapsed time limit for a session, expressed in minutes.
IDLE_TIMESpecify the permitted periods of continuous inactive time during a session, expressed in minutes. Long-running queries and other operations are not subject to this limit.
3.使用create user 或alter user命令把profile分配给用户。
SQL> create user qs identified by qs profile test; --创建用户时指定profile
User created.
SQL> alter user qs profile test; --修改用户的profile
User altered.
SQL>
SQL> alter user dinya profile default; --还原默认值
4.修改PROFILE
SQL> alter profile test limit idle_time 60;
Profile altered.
5.删除PROFILE
SQL> drop profile test;
SQL> drop profile test cascade;
SQL> set wrap off;
SQL> select profile from dba_users where username='QS';
PROFILE
------------------------------
TEST
SQL> select * from dba_profiles where profile='TEST';
PROFILE RESOURCE_NAME RESOURCE LIMIT
------------------------------ -------------------------------- -------- -------
TEST COMPOSITE_LIMIT KERNEL DEFAULT
TEST SESSIONS_PER_USER KERNEL DEFAULT
TEST CPU_PER_SESSION KERNEL DEFAULT
TEST CPU_PER_CALL KERNEL DEFAULT
TEST LOGICAL_READS_PER_SESSION KERNEL DEFAULT
TEST LOGICAL_READS_PER_CALL KERNEL DEFAULT
TEST IDLE_TIME KERNEL 60
TEST CONNECT_TIME KERNEL 480
TEST PRIVATE_SGA KERNEL DEFAULT
TEST FAILED_LOGIN_ATTEMPTS PASSWORD DEFAULT
TEST PASSWORD_LIFE_TIME PASSWORD DEFAULT
PROFILE RESOURCE_NAME RESOURCE LIMIT
------------------------------ -------------------------------- -------- -------
TEST PASSWORD_REUSE_TIME PASSWORD DEFAULT
TEST PASSWORD_REUSE_MAX PASSWORD DEFAULT
TEST PASSWORD_VERIFY_FUNCTION PASSWORD DEFAULT
TEST PASSWORD_LOCK_TIME PASSWORD DEFAULT
TEST PASSWORD_GRACE_TIME PASSWORD DEFAULT