CREATE TEMPORARY TABLESPACE test_temp
TEMPFILE ' C:\oracle\product\10.1.0\oradata\orcl\test_temp01.dbf '
SIZE 32M
AUTOEXTEND ON
NEXT 32M MAXSIZE 2048M
EXTENT MANAGEMENT LOCAL;
创建用户表空间
创建用户表空间
CREATE TABLESPACE test_data
LOGGING
DATAFILE ' C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL\TEST_DATA01.DBF '
SIZE 32M
AUTOEXTEND ON
NEXT 32M MAXSIZE 2048M
EXTENT MANAGEMENT LOCAL;
创建用户并制定表空间
CREATE USER username IDENTIFIED BY password
DEFAULT TABLESPACE TEST_DATA
TEMPORARY TABLESPACE TEST_TEMP;
给用户授予权限
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 username;
将role这个角色授与username,也就是说,使username这个用户可以管理和使用role所拥有的资源
GRANT role TO username;
-----------------------------------------------查看用户权限---------------------------------------------------------
查看所有用户
SELECT * FROM DBA_USERS;
SELECT * FROM ALL_USERS;
SELECT * FROM USER_USERS;
查看用户系统权限
SELECT * FROM DBA_SYS_PRIVS;
SELECT * FROM USER_SYS_PRIVS;
查看用户对象或角色权限
SELECT * FROM DBA_TAB_PRIVS;
SELECT * FROM ALL_TAB_PRIVS;
SELECT * FROM USER_TAB_PRIVS;
查看所有角色
SELECT * FROM DBA_ROLES;
查看用户或角色所拥有的角色
SELECT * FROM DBA_ROLE_PRIVS;
SELECT * FROM USER_ROLE_PRIVS;
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.查看角色(只能查看登陆用户拥有的角色)所包含的权限 sql>select * from role_sys_privs; 4.查看用户对象权限: select * from dba_tab_privs; select * from all_tab_privs; select * from user_tab_privs; 5.查看所有角色: select * from dba_roles; 6.查看用户或角色所拥有的角色: select * from dba_role_privs; select * from user_role_privs; 7.查看哪些用户有sysdba或sysoper系统权限(查询时需要相应权限) select * from V$PWFILE_USERS 注意: 1、以下语句可以查看Oracle提供的系统权限 select name from sys.system_privilege_map 2、查看一个用户的所有系统权限(包含角色的系统权限) Sql代码 select privilege from dba_sys_privs where grantee='DATAUSER' union select privilege from dba_sys_privs where grantee in (select granted_role from dba_role_privs where grantee='DATAUSER' ); 1.查看当前用户所拥有的系统权限 select * from session_privs; 2.查看数据库内的所有角色 selec * from dba_roles; 3.查看数据库所支持的最大角色数 SQL> show parameter role max_enabled_roles integer 150 --该值可以修改 os_roles boolean FALSE remote_os_roles boolean FALSE 4.查看当前用户所拥有的角色 select * from session_roles; 5.查看角色的嵌套关系和所授予的用户 select * from dba_role_privs order by 1; 6.其他查看角色和权限的命令 select * from role_sys_privs; select * from dba_sys_privs; 7.表级对象权限 select * from user_tab_privs_made; select * from user_tab_privs_recd; 8.列上的对象权限 select * from user_col_privs_made; select * from user_col_privs_recd; 9.比较connect和resoucr角色的权限差别 SQL> select grantee,privilege from dba_sys_privs where grantee='RESOURCE' OR GRANTEE LIKE 'CONNECT%' CONNECT CREATE VIEW CONNECT CREATE TABLE CONNECT ALTER SESSION CONNECT CREATE CLUSTER CONNECT CREATE SESSION CONNECT CREATE SYNONYM CONNECT CREATE SEQUENCE CONNECT CREATE DATABASE LINK RESOURCE CREATE TYPE RESOURCE CREATE TABLE RESOURCE CREATE CLUSTER RESOURCE CREATE TRIGGER RESOURCE CREATE OPERATOR RESOURCE CREATE SEQUENCE RESOURCE CREATE INDEXTYPE RESOURCE CREATE PROCEDURE 已选择16行。 10.查看oracle的版本,其实查看oracle的版本还有许多其他方法,不过我认为下面这个方法 比较好记。 SQL> select version from v$instance; 10.1.0.2.0 注意: 我做该实验的oracle版本是10.1.0.2.0。 CONNECT角色在10g以后就只有create session的权限了,以前其他版本的权限都被取消了。 当RESOURCE角色被授予一个用户后,该用户自动拥有了unlimited tablespace的系统权限。