Oracle用户管理

一、创建用户的Profile文件

SQL> create profile student limit  // student为资源文件名
FAILED_LOGIN_ATTEMPTS  3  //指定锁定用户的登录失败次数
PASSWORD_LOCK_TIME 5  //指定用户被锁定天数
PASSWORD_LIFE_TIME 30  //指定口令可用天数

二、创建用户

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;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值