查看所有用户
select * from all_users;
查看当前用户的权限
select * from user_sys_privs;
创建用户
create user u2 identified by u2;
授予用户建立连接和建表权限
grant create session,create table to u2;
连接到u2
conn u2/u2
查看账号属性
select * from user_users;
创建摘要文件pfile[profile文件可以用于管理登录参数]
create profile p2 limit FAILED_LOGIN_ATTEMPTS 3
PASSWORD_LOCK_TIME 1;
将pfile赋予用户
alter user u2 profile p2;
验证是否授予成功
select username,profile from dba_users;
检验p1效果
sys@ORCL> conn u2/1
ERROR:
ORA-01017: invalid username/password; logon denied
警告: 您不再连接到 ORACLE。
sys@ORCL> conn u2/2
ERROR:
ORA-01017: invalid username/password; logon denied
sys@ORCL> conn u2/3
ERROR:
ORA-01017: invalid username/password; logon denied
sys@ORCL> conn u2/4
ERROR:
ORA-28000: the account is locked
sys@ORCL>
连续输错四次密码,令账户被锁
sysdba身份登录查看
sys@ORCL> conn sys/**** as sysdba
已连接。
sys@ORCL> select username,account_status from dba_users where username='U2';
USERNAME ACCOUNT_STATUS
-----------------------------------------------------------
U2 LOCKED(TIMED)
sys@ORCL>
账号解锁
alter user u2 account unlock;