第十三章 用户及系统资源管理(概要文件)
<p>[TOC]</p>
<h2>创建用户</h2>
<ul>
<li>
<p>创建用户dog</p>
<pre><code>create user dog identified by wangwang
default tablespace PIONEER_DATA
temporary tablespace PIONEER_TEMP
quota 68M on PIONEER_DATA
quota 28M on USERS
password expire;</code></pre>
</li>
<li>
<p>查看创建的用户情况</p>
<pre><code>select username, default_tablespace, temporary_tablespace, created
from dba_users
where default_tablespace = 'PIONEER_DATA';</code></pre>
</li>
<li>查看用户表空间使用情况
<pre><code>select username,
tablespace_name,
bytes / 1024 / 1024 MB,
max_bytes / 1024 / 1024 "Max MB"
from dba_ts_quotas
where username = 'DOG';</code></pre></li>
</ul>
<h2>数据库模式、方案,跟用户差不多</h2>
<h2>改变用户在表空间上的配额</h2>
<pre><code>alter user dog quota 0 on users;
alter user dog quota 38M on pioneer_data;</code></pre>
<h2>删除用户</h2>
<pre><code>drop user dog;
drop user dog cascade ;
select * from dba_users where default_tablespace not like'SYS%' and length(username)<6</code></pre>
<h2>用户的安全控制域</h2>
<ul>
<li>安全检测、表空间、表空间配额、锁、资源限制、权限</li>
<li>引入概要文件批量管理</li>
</ul>
<h2>概要文件</h2>
<ul>
<li>一组命了名的口令和资源限制</li>
<li>授予概要文件用户:<code>create user \alter user</code></li>
</ul>
<h2>利用概要文件进行资源管理</h2>
<ul>
<li><code>create profile</code> 命令创建概要文件</li>
<li><code>create user\alter user</code> 分配概要文件至用户</li>
<li><code>alter system set resource_limit=true</code> 开启资源限制</li>
</ul>
<h2>资源限制的设置</h2>
<ul>
<li>会话一级、调用一级</li>
</ul>
<h2>创建资源限制的概要文件</h2>
<ul>
<li><code>pesource_type=KERNEL</code> 资源限制</li>
<li>
<p><code>pesource_type=PASSWORD</code> 安全口令限制</p>
</li>
<li>
<p>创建资源限制的概要文件</p>
<pre><code>create profile luck_prof limit
SESSIONS_PER_USER 8
CPU_PER_SESSION 16800
LOGICAL_READS_PER_SESSION 23688
CONNECT_TIME 268
IDLE_TIME 38 ;</code></pre>
</li>
<li>查询概要文件
<code>select * from dba_profiles where profile like 'LUCK%';</code></li>
</ul>
<h2>口令限制</h2>
<ul>
<li><code>create profile</code> 命令创建概要文件口令限制</li>
<li><code>create user\alter user</code> 分配概要文件至用户</li>
<li>运行<code>$ORACLE_HOME/rdbms/admin/utlpwdmg.sql</code> 文件开启口令限制</li>
</ul>
<h2>口令验证函数</h2>
<ul>
<li>不重要
运行<code>$ORACLE_HOME/rdbms/admin/utlpwdmg.sql</code> 文件开启口令限制
自动生成<code>verify_function</code> 函数用于校验口令
自动执行<code>alter profile default</code>语句</li>
</ul>
<h2>创建口令限制的概要文件</h2>
<ul>
<li>
<p>创建口令限制的概要文件</p>
<pre><code>create profile unluck_prof limit
FAILED_LOGIN_ATTEMPTS 7
PASSWORD_LOCK_TIME UNLIMITED
PASSWORD_LIFE_TIME 44
PASSWORD_REUSE_TIME 24
PASSWORD_GRACE_TIME 4 ;</code></pre>
</li>
<li>查询概要文件
<code>select * from dba_profiles where profile like 'UNLUCK%' and resource_type='PASSWORD';</code></li>
</ul>
<h2>修改和删除概要文件</h2>
<ul>
<li>
<p>查询所有概要文件
<code>select * from dba_profiles where resource_name='PASSWORD_LIFE_TIME';</code></p>
</li>
<li>
<p>修改profile 文件</p>
<pre><code>alter profile unluck_prof limit
FAILED_LOGIN_ATTEMPTS 4
PASSWORD_LIFE_TIME 74
PASSWORD_GRACE_TIME 14 ;</code></pre>
</li>
<li>删除profile 文件
<pre><code>drop profile LUCK_PROF;
drop profile UNLUCK_PROF cascade;</code></pre></li>
</ul>
<h2>创建概要文件实例</h2>
<ul>
<li>
<p>创建概要文件</p>
<pre><code>create profile pioneer_prof limit
FAILED_LOGIN_ATTEMPTS 4
PASSWORD_LOCK_TIME UNLIMITED
PASSWORD_LIFE_TIME 91
PASSWORD_REUSE_TIME 28
PASSWORD_GRACE_TIME 7
SESSIONS_PER_USER 3
CPU_PER_SESSION 16800
LOGICAL_READS_PER_SESSION 23688
CONNECT_TIME 180
IDLE_TIME 38;</code></pre>
</li>
<li>查询创建文件
<code>select * from dba_profiles where profile like 'PIO%' ;</code></li>
</ul>