oracle 为 用户 解锁 加锁 (以hr为例)

oracle 为 用户 解锁 加锁 (以hr为例)

>sqlplus  / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on 星期日 10月 16 08:08:45 2011
Copyright (c) 1982, 2010, Oracle.  All rights reserved.

连接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> desc dba_users;   ####描述dba_users
 
     
可能会报错:
ORA-01012: not logged on
 
     
解决办法:重新打开数据库SQL>startup
SQL> desc dba_users; 
名称 是否为空? 类型 ----------------------------------------- -------- ---------------------------- USERNAME NOT NULL VARCHAR2(30) USER_ID NOT NULL NUMBER PASSWORD VARCHAR2(30) ACCOUNT_STATUS NOT NULL VARCHAR2(32) LOCK_DATE DATE EXPIRY_DATE DATE DEFAULT_TABLESPACE NOT NULL VARCHAR2(30) TEMPORARY_TABLESPACE NOT NULL VARCHAR2(30) CREATED NOT NULL DATE PROFILE NOT NULL VARCHAR2(30) INITIAL_RSRC_CONSUMER_GROUP VARCHAR2(30) EXTERNAL_NAME VARCHAR2(4000) PASSWORD_VERSIONS VARCHAR2(8) EDITIONS_ENABLED VARCHAR2(1) AUTHENTICATION_TYPE VARCHAR2(8)SQL> select username, account_status from dba_users order by username;USERNAME ACCOUNT_STATUS------------------------------ --------------------------------ANONYMOUS EXPIRED & LOCKEDAPEX_030200 EXPIRED & LOCKEDAPEX_PUBLIC_USER EXPIRED & LOCKEDAPPQOSSYS EXPIRED & LOCKEDBI EXPIRED & LOCKEDCTXSYS EXPIRED & LOCKEDDBSNMP OPENDIP EXPIRED & LOCKEDEXFSYS EXPIRED & LOCKEDFLOWS_FILES EXPIRED & LOCKED *HR EXPIRED & LOCKED* ###此时hr状态为过期并且锁住USERNAME ACCOUNT_STATUS------------------------------ --------------------------------IX EXPIRED & LOCKEDMDDATA EXPIRED & LOCKEDMDSYS EXPIRED & LOCKEDMGMT_VIEW OPENOE EXPIRED & LOCKEDOLAPSYS EXPIRED & LOCKEDORACLE_OCM EXPIRED & LOCKEDORDDATA EXPIRED & LOCKEDORDPLUGINS EXPIRED & LOCKEDORDSYS EXPIRED & LOCKEDOUTLN EXPIRED & LOCKEDUSERNAME ACCOUNT_STATUS------------------------------ --------------------------------OWBSYS EXPIRED & LOCKEDOWBSYS_AUDIT EXPIRED & LOCKEDPM EXPIRED & LOCKEDSCOTT OPENSH EXPIRED & LOCKEDSI_INFORMTN_SCHEMA EXPIRED & LOCKEDSPATIAL_CSW_ADMIN_USR EXPIRED & LOCKEDSPATIAL_WFS_ADMIN_USR EXPIRED & LOCKEDSYS OPENSYSMAN OPENSYSTEM OPENUSERNAME ACCOUNT_STATUS------------------------------ --------------------------------WMSYS EXPIRED & LOCKEDXDB EXPIRED & LOCKEDXS$NULL EXPIRED & LOCKED已选择36行。SQL> *alter user hr account unlock;* ####更改用户hr帐户为未锁用户已更改。SQL> select username, account_status from dba_users order by username;USERNAME ACCOUNT_STATUS------------------------------ --------------------------------ANONYMOUS EXPIRED & LOCKEDAPEX_030200 EXPIRED & LOCKEDAPEX_PUBLIC_USER EXPIRED & LOCKEDAPPQOSSYS EXPIRED & LOCKEDBI EXPIRED & LOCKEDCTXSYS EXPIRED & LOCKEDDBSNMP OPENDIP EXPIRED & LOCKEDEXFSYS EXPIRED & LOCKEDFLOWS_FILES EXPIRED & LOCKED *HR EXPIRED* ####此时hr只是过期并没有被锁住USERNAME ACCOUNT_STATUS------------------------------ --------------------------------IX EXPIRED & LOCKEDMDDATA EXPIRED & LOCKEDMDSYS EXPIRED & LOCKEDMGMT_VIEW OPENOE EXPIRED & LOCKEDOLAPSYS EXPIRED & LOCKEDORACLE_OCM EXPIRED & LOCKEDORDDATA EXPIRED & LOCKEDORDPLUGINS EXPIRED & LOCKEDORDSYS EXPIRED & LOCKEDOUTLN EXPIRED & LOCKEDUSERNAME ACCOUNT_STATUS------------------------------ --------------------------------OWBSYS EXPIRED & LOCKEDOWBSYS_AUDIT EXPIRED & LOCKEDPM EXPIRED & LOCKEDSCOTT OPENSH EXPIRED & LOCKEDSI_INFORMTN_SCHEMA EXPIRED & LOCKEDSPATIAL_CSW_ADMIN_USR EXPIRED & LOCKEDSPATIAL_WFS_ADMIN_USR EXPIRED & LOCKEDSYS OPENSYSMAN OPENSYSTEM OPENUSERNAME ACCOUNT_STATUS------------------------------ --------------------------------WMSYS EXPIRED & LOCKEDXDB EXPIRED & LOCKEDXS$NULL EXPIRED & LOCKED已选择36行。SQL> *alter user hr identified by hr;* ####更改用户hr的密码为hr用户已更改。SQL> select username, account_status from dba_users order by username;USERNAME ACCOUNT_STATUS------------------------------ --------------------------------ANONYMOUS EXPIRED & LOCKEDAPEX_030200 EXPIRED & LOCKEDAPEX_PUBLIC_USER EXPIRED & LOCKEDAPPQOSSYS EXPIRED & LOCKEDBI EXPIRED & LOCKEDCTXSYS EXPIRED & LOCKEDDBSNMP OPENDIP EXPIRED & LOCKEDEXFSYS EXPIRED & LOCKEDFLOWS_FILES EXPIRED & LOCKED *HR OPEN* ####此时hr状态为OPENUSERNAME ACCOUNT_STATUS------------------------------ --------------------------------IX EXPIRED & LOCKEDMDDATA EXPIRED & LOCKEDMDSYS EXPIRED & LOCKEDMGMT_VIEW OPENOE EXPIRED & LOCKEDOLAPSYS EXPIRED & LOCKEDORACLE_OCM EXPIRED & LOCKEDORDDATA EXPIRED & LOCKEDORDPLUGINS EXPIRED & LOCKEDORDSYS EXPIRED & LOCKEDOUTLN EXPIRED & LOCKEDUSERNAME ACCOUNT_STATUS------------------------------ --------------------------------OWBSYS EXPIRED & LOCKEDOWBSYS_AUDIT EXPIRED & LOCKEDPM EXPIRED & LOCKEDSCOTT OPENSH EXPIRED & LOCKEDSI_INFORMTN_SCHEMA EXPIRED & LOCKEDSPATIAL_CSW_ADMIN_USR EXPIRED & LOCKEDSPATIAL_WFS_ADMIN_USR EXPIRED & LOCKEDSYS OPENSYSMAN OPENSYSTEM OPENUSERNAME ACCOUNT_STATUS------------------------------ --------------------------------WMSYS EXPIRED & LOCKEDXDB EXPIRED & LOCKEDXS$NULL EXPIRED & LOCKED已选择36行。SQL> conn hr/hr ####以hr帐户登陆已连接。SQL> show user;USER 为 "HR"

你可能感兴趣的:(oracle)