【Oracle XE系列之二】Oracle XE创建表空间、创建用户以及授权、查看权限

一、创建表空间

1、临时表空间

CREATE TEMPORARY TABLESPACE zhunian_temp
TEMPFILE 'D:\OracleXE\app\oracle\oradata\XE\zhunian_temp.dbf '
SIZE 32M
AUTOEXTEND ON
NEXT 32M MAXSIZE 2048M
EXTENT MANAGEMENT LOCAL;

2、创建用户表空间

CREATE TABLESPACE zhunian_data
LOGGING
DATAFILE 'D:\OracleXE\app\oracle\oradata\XE\zhunian_data.dbf '  
SIZE 32M 
AUTOEXTEND ON
NEXT 32M MAXSIZE 2048M
EXTENT MANAGEMENT LOCAL;

二、创建用户

1、创建用户并指定表空间

CREATE USER zhunian IDENTIFIED BY <PASSWORD>
DEFAULT TABLESPACE ZHUNIAN_DATA
TEMPORARY TABLESPACE ZHUNIAN_TEMP; 

2、给用户授予权限

GRANT CREATE SESSION,DBA TO zhunian;

我这里偷懒直接给了dba权限,实际授权可以更细致,例如:

GRANT  
   CREATE SESSION,CREATE ANY TABLE,CREATE ANY VIEW,CREATE ANY INDEX,CREATE ANY PROCEDURE,
   ALTER ANY TABLE,ALTER ANY PROCEDURE,
   DROP ANY TABLE,DROP ANY VIEW,DROP ANY INDEX,DROP ANY PROCEDURE,
   SELECT ANY TABLE,INSERT ANY TABLE,UPDATE ANY TABLE,DELETE ANY TABLE
TO  zhunian; 

当然,也可以将角色role授予用户zhunian,也就是说,使zhunian这个用户可以管理和使用role所拥有的资源,语法如下:

GRANT  role  TO  zhunian;

3、查看用户权限

1>查看所有用户

SELECT * FROM DBA_USERS;
SELECT * FROM ALL_USERS;
SELECT * FROM USER_USERS; 

2>查看用户系统权限

SELECT * FROM DBA_SYS_PRIVS;
SELECT * FROM USER_SYS_PRIVS; 

3>查看用户对象或角色权限

SELECT * FROM DBA_TAB_PRIVS;
SELECT * FROM ALL_TAB_PRIVS;
SELECT * FROM USER_TAB_PRIVS; 

4>查看所有角色

SELECT * FROM DBA_ROLES; 

5>查看用户或角色所拥有的角色

SELECT * FROM DBA_ROLE_PRIVS;
SELECT * FROM USER_ROLE_PRIVS; 

 

表空间相关扩展见:http://www.cnblogs.com/renjie08317/archive/2012/11/02/2750849.html

 

转载请注明出处

http://www.cnblogs.com/zhunian/archive/2012/10/31/2748723.html   

http://www.zhunian.iego.cn

posted @ 2012-11-08 16:02  今心  阅读(2297)  评论(0编辑  收藏  举报