Oracle 用户管理
1.创建新的表空间:
create tablespace newxxt
datafile
'/oradata/dduyoung/newxxt1.dbf' size 200M autoextend on next 10M maxsize unlimited,
'/oradata/dduyoung/newxxt2.dbf' size 200M autoextend on next 10M maxsize unlimited
extent management local
segment space management auto;
datafile
'/oradata/dduyoung/newxxt1.dbf' size 200M autoextend on next 10M maxsize unlimited,
'/oradata/dduyoung/newxxt2.dbf' size 200M autoextend on next 10M maxsize unlimited
extent management local
segment space management auto;
2.创建新的用户:
create user dduyoung identified by psw123
default tablespace newxxt
temporary tablespace temp
default tablespace newxxt
temporary tablespace temp
3.创建新的角色并给角色赋予权限:
create role ddu;
grant connect,resource to ddu;
grant dba to ddu;
grant connect,resource to ddu;
grant dba to ddu;
4.修改用户在表空间上的配额:
alter user dduyoung quota unlimited on newxxt
------------------------------------------------------------------------------
如果给用户分配一个表空间,但是不给用户在该表空间上相应的配额(用户在该表空间上可以使用的空间),用户依然不能在这个空间上做修改(如新建表格)。
5.修改用户属性:
Alter user dduyoung
IDENTIFIED BY pwd456
Default tablespace oldxxt
TEMPORARY tablespace temp
Profile myprof
Quota 50M on oldxxt;
IDENTIFIED BY pwd456
Default tablespace oldxxt
TEMPORARY tablespace temp
Profile myprof
Quota 50M on oldxxt;
6.锁定帐号:
Alter user dduyoung ACCOUNT LOCK; - -加锁
Alter user dduyoung ACCOUNT UNLOCK; - -解锁
Alter user dduyoung ACCOUNT UNLOCK; - -解锁
7.强制使用用户密码失效:
alter user dduyoung password expire;
8.删除用户:
--用户下没有实体时
Drop user dduyoung;
--用户已创建实体如表和数据时
Drop user dduyoung CASCADE;
--注意:当前正连接的用户不得删除。使用CASCADE选项时,
--用户及实体马上被删除,应再进入数据文件进行物理删除。
Drop user dduyoung;
--用户已创建实体如表和数据时
Drop user dduyoung CASCADE;
--注意:当前正连接的用户不得删除。使用CASCADE选项时,
--用户及实体马上被删除,应再进入数据文件进行物理删除。
9.监视用户:
--查询用户会话信息:(如果有两个用户以同一用户名登录,则可动态查询
Select username ,machine , sid , serial# From V$session;
--删除会话
Alter system kill session 'sid , serial' ;
--查看用户的SqL语句
Select user_name , SQL_text From V$open_cursor where user_name = upper('dduyoung');
Select username ,machine , sid , serial# From V$session;
--删除会话
Alter system kill session 'sid , serial' ;
--查看用户的SqL语句
Select user_name , SQL_text From V$open_cursor where user_name = upper('dduyoung');