例
1.创建用户
创建用户user3,口令为user3,默认表空间为USERS,在该表空间里的配额为10MB,初始状态为锁定状态
SQL> create user user3 identified by user3 default tablespace users quota 10M on users account lock;
User created.
创建一个用户user4,口令为user4,默认表空间为users,配额为10MB,口令设置为过期状态,即首次连接时需要修改密码,配置文件为pwd_profile(假设此文件已经建立)
SQL> create user user4 identified by user4 default tablespace users quota 10M on users profile pwd_profile password expire;
User created.
创建操作系统验证用户
SQL> create user hxy2 identified externally default tablespace users temporary tablespace temp quota 10M on datapassword expire;
create user hxy2 identified externally default tablespace users temporary tablespace temp quota 10M on data password expire
*
ERROR at line 1:
ORA-28010: cannot expire external or global accounts
创建操作系统验证用户,不能使用过期的密码
SQL> create user hxy2 identified externally default tablespace users temporary tablespace temp quota 10M on data;
User created.
2.修改用户
修改用户user3的口令为newuser3,同时将该用户解锁
SQL> alter user user3 identified by newuser3 account unlock;
User altered.
修改用户user4的默认表空间为orcltbs1,在users表空间的配额为20MB
SQL> alter user user4 default tablespace orcltbs1 quota 20m on users;
User altered.
3.删除用户
SQL> drop user user4;
User dropped.
如果用户拥有数据库对象,则必须在drop user 语句中使用cascade,Oracle先删除用户的所有对象,再删除用户。
4.查询用户信息
SQL> select * from all_users;
USERNAME USER_ID CREATED
------------------------------ ---------- ---------
HXY2 71 08-JAN-13
HXY 59 07-JAN-13
USER5 66 08-JAN-13
SCOTT 61 07-JAN-13
MGMT_VIEW 53 06-JAN-13
USER3 67 08-JAN-13
MDDATA 50 06-JAN-13
SYSMAN 51 06-JAN-13
MDSYS 46 06-JAN-13
SI_INFORMTN_SCHEMA 45 06-JAN-13
ORDPLUGINS 44 06-JAN-13
ORDSYS 43 06-JAN-13
OLAPSYS 47 06-JAN-13
查询数据库中各用户的登陆时间,会话号等
SQL> select sid,serial#,logon_time,username from v$session;
SID SERIAL# LOGON_TIM USERNAME
---------- ---------- --------- ------------------------------
122 1388 08-JAN-13 DBSNMP
125 1943 08-JAN-13
130 5236 08-JAN-13 SYSMAN
131 7611 08-JAN-13 SYSMAN
133 2191 08-JAN-13 SYSMAN
140 1997 08-JAN-13 SYS
