暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

Oracle数据库用户管理

原创 北斗 2023-07-21
263

Oracle用户管理

一、创建用户的Profile文件
SQL> create profile student limit // student为资源文件名
FAILED_LOGIN_ATTEMPTS 3 //指定锁定用户的登录失败次数
PASSWORD_LOCK_TIME 5 //指定用户被锁定天数
PASSWORD_LIFE_TIME 30 //指定口令可用天数
二、创建用户
在创建用户之前,可以登录系统管理员权限去创建一个用户(因为系统管理员有这个权限),下面是三种用户分类:
sys; //系统管理员,拥有最高权限
system;//本地管理员,次高权限
scott; //普通用户,密码默认为tiger,默认未解锁

SQL> Create User username
Identified by password
Default Tablespace tablespace
Temporary Tablespace tablespace
Profile profile
Quota integer/unlimited on tablespace;
例:
SQL> Create user acc01
identified by acc01 // 如果密码是数字,请用双引号括起来
default tablespace account
temporary tablespace temp
profile default
quota 50m on account;
SQL> grant connect, resource to acc01;
[*] 查询用户缺省表空间、临时表空间
SQL> select username, default_tablespace, temporary_tablespace from dba_users;
[*] 查询系统资源文件名:
SQL> select * from dba_profiles;
资源文件类似表,一旦创建就会保存在数据库中。
SQL> select username, profile, default_tablespace, temporary_tablespace from dba_users;
SQL> create profile common limit
failed_login_attempts 5
idle_time 5;
SQL> Alter user acc01 profile common;
三、修改用户:
SQL> Alter User 用户名
Identified 口令
Default Tablespace tablespace
Temporary Tablespace tablespace
Profile profile
Quota integer/unlimited on tablespace;
1、修改口令字:
SQL>Alter user acc01 identified by “12345”;
2、修改用户缺省表空间:
SQL> Alter user acc01 default tablespace users;
3、修改用户临时表空间
SQL> Alter user acc01 temporary tablespace temp_data;
4、强制用户修改口令字:
SQL> Alter user acc01 password expire;
5、将用户加锁
SQL> Alter user acc01 account lock; // 加锁
SQL> Alter user acc01 account unlock; // 解锁
四、删除用户
SQL>drop user 用户名; //用户没有建任何实体
SQL> drop user 用户名 CASCADE; // 将用户及其所建实体全部删除
*1. 当前正连接的用户不得删除。
五、监视用户:
1、查询用户会话信息:
SQL> select username, sid, serial#, machine from v$session;  
2、删除用户会话信息:  
SQL> Alter system kill session ‘sid, serial#’;  
3、查询用户SQL语句:  
SQL> select user_name, sql_text from v$open_cursor;

「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论