Oracle数据库的用户管理

一、用户创建的语法


⚠️externally创建外部用户:这样的用户必须由外部服务,例如操作系统或第三方服务进行身份验证,以确保外部用户访问特定的数据库用户。

1.常规用户创建的语法:

create user 名字 identified by 密码

default tablespace ???                        --默认的表空间。

temporary tablespace ???                   --默认的临时表空间。

quota 数字[k/m] on ???                      --指定在某个表空间的磁盘配额。

profile ???                                        --指定默认的参数文件。

password expire                               --账户过期,首次登录提示修改密码。

account [lock/unlock];                       --指定账户是否锁定。

2.新建用户的授权

SQL>grant connect, resource to newuser;

3.用户信息的查询

SQL>select user_id,username,password,account_status,lock_date,expiry_date,default_tablespace,temporary_tablespace,created,profile,authentication_type, from dba_user where username='???';

4.用户解锁

SQL>alter user 用户名 account unlock;

5.如果创建用户时未指定默认的表空间和临时表空间,可通过查看database_properties数据字典(存储永久的数据库熟悉)内的默认值,



SQL>select * from database_properties

2 where property_name in

3('default_temp_tablespace','default_permanent_tablespace')

6.指定用户的临时表空间

SQL>alter user 用户名 temporary tablespace 数据库内临时表空间的名


7.用户的删除

用户可被删除的原则:包含对象的用户不可以被删除,需加‘cascade’

二、用户的profile

1.用户的profile是用来限制数据库用户在系统资源和密码参数上的命名集合


session_per_user     --每个用户可以并行开启的多少个会话

cpu_per_session      --每个会话使用CPU的时间,单位是百分之一秒。

cpu_per_call            --每次调用使用CPU的时间,单位是百分之一秒。

connect_time           --会话连接时间,单位是分钟。

idle_time                 --空闲中断时间,单位是分钟。

logical_reads_per_session    --每个会话每次逻辑读的数据块数量,单位是块。

logic_reads_per_call            --每次调用发生逻辑读的数据块的数量,单位是块。

composite_limit                  --综合资源限制

private_sga                        --可以在sga中share_pool的空间。


密码文件参数说明:

fail_login_attempts       --密码错误输入次数

password_life_time       --密码使用期限,单位是天。 

password_reuse_time   --密码可重用的时间间隔,单位是天。

password_reuse_max    --密码重用最大次数。

password_lock_time      --密码锁定天数,单位是天。

password_grace_time    --密码到期提前通知天数。

password_verify_function   --密码强度验证函数。

2.查看数据库内的profile

SQL>select * from dba_profiles

3.产生密码强度验证函数

$ORACLE_HOME/rdbms/admin/utlpwdmg.sql

4.查看密码强度验证函数

SQL>select * from dba_profiles where resource_type='PASSWORD'

PROFILE                        RESOURCE_NAME                        RESOURCE LIMIT
------------------------------ ------------------------------------------ -------------------------------------------------
DEFAULT                       PASSWORD_VERIFY_FUNCTION   PASSWORD VERIFY_FUNCTION        --10g产生的信息

DEFAULT             PASSWORD_VERIFY_FUNCTION  PASSWORD VERIFY_FUNCTION_11G    --11g产生的信息

5.添加或者删除密码强度验证函数的操作

SQL>alter profile 名字 limit password_verify_function null; --取消函数验证。

SQL>alter profile 名字 limit password_verify_function verify_function_11g    --这里以11g数据库为例添加强度函数验证机制。

6.资源参数创建的案例

SQL>create profile newprofile

2    resource_limit=true        --启用资源限制

⚠️如果新建的profile内未添加此行,可在外部执行SQL>alter system set resource_limit=true;

3    limit

4    idle_time 20                 --空闲中断时间20分钟

5    failed_login_attempts 5      --密码错误输入次数

6    password_lock_time 1/1440  --默认时间单位为“天”,这里面一分钟的表达

7    password_grace_time 2        --密码过期提前2天通知

8   password_life_time 60         --密码生命周期60天

三、profile的管理

1.查询一个profile

SQL>select * from dba_profiles where profile='名字';

2.修改profile的信息  (以失败登录次数举例)

SQL>alter profile 名字 limit failed_login_attemptts 5

3.删除profile

能删除的原则:待删除的profile没有用户被授予使用或者在SQL>drop profile 名字 cascade;

猜你喜欢

转载自blog.csdn.net/fc_barceiona/article/details/79418976