当前用户:
如何查看当前连接的用户
how user;
select sys_context( 'userenv ', 'session_user ') from dual;
select user from dual;
查看所有登录的用户
select username from v$session;
SQL> select count(*) from v$session;
COUNT(*)
----------
26
SQL> select machine,terminal from v$session;
SQL> select * from user_role_privs;
USERNAME GRANTED_ROLE ADM DEF OS_
------------------------------ ------------------------------ --- --- ---
SYSTEM AQ_ADMINISTRATOR_ROLE YES YES NO
SYSTEM DBA YES YES NO
SYSTEM MGMT_USER NO YES NO
解决办法:查DBA_USERS表,可以看到用户的状态。是否被锁住(变成LOCKED(TIMED)状态了说明用户被锁定)。
SQL> select USERNAME , ACCOUNT_STATUS from dba_users;
USERNAME ACCOUNT_STATUS
------------------------------ --------------------------------
MGMT_VIEW OPEN
SYS OPEN
SYSTEM OPEN
DBSNMP OPEN
SYSMAN OPEN
SCOTT OPEN
OUTLN EXPIRED & LOCKED
select * from USER_HISTORY$ –查看用户口令是否过期
select * from dba_profiles –查看用户使用的profile设置
解决:
sqlplus /nolog
conn /as sysdba
alter user account unlock; –解锁
alter user password expire; –密码过期
alter user identified by ; –重设密码
或者 alter profile default limit failed_login_Attempts unlimited;
然后登录即可
【注】若要查看任一账户的口令限期,可查询DBA_USERS数据字典视图的Expire_Date列。若用户自己想查看,可查询USER_USERS数据字典视图的Expiry_Date列(通过SQL*Plus或一个基于客户机的查询工具)。