Oracle创建表空间及用户

一、创建表空间

1、设置实例名

echo $ORACLE_SID

export ORACLE_SID=mvbpbang

2、sqlplus登录/sqlplus命令登录

  在安装Oracle时,你需要记住设置的“全局数据库名”(默认为orcl) 和 口令,在以两种方式登录时:

  用户名: sys(超级用户==sysdba) / system(管理员用户 和sys想比区别在于system不能创建表空间)...

  口 令:sqlplus  / as sysdba;

3、创建临时表空间/表空间/创建用户/授权

  

  

 
1:创建临时表空间
create temporary tablespace user_temp  
tempfile 'Q:oracleproduct10.2.0oradataTestxyrj_temp.dbf' 
size 50m  
autoextend on  
next 50m maxsize 20480m  
extent management local;  
 
2:创建数据表空间
create tablespace user_data   
datafile 'Q:oracleproduct10.2.0oradataTestxyrj_data.dbf' 
size 50m  
autoextend on  
next 50m maxsize unlimited  
extent management local
segment space management auto; 第3步:创建用户并指定表空间 create user username identified by password default tablespace user_data temporary tablespace user_temp; 第4步:给用户授予权限 grant connect,resource,dba to username;
 

二、删除用户及表空间 

删除user

drop user ×× cascade

说明: 删除了user,只是删除了该user下的schema objects,是不会删除相应的tablespace的。

 删除tablespace

drop  tablespace tablespace_name  including contents and datafiles;

 


SQL code
--删除空的表空间,但是不包含物理文件
drop tablespace tablespace_name;
--删除非空表空间,但是不包含物理文件
drop tablespace tablespace_name including contents;


--删除空表空间,包含物理文件
drop tablespace tablespace_name including datafiles;
--删除非空表空间,包含物理文件
drop tablespace tablespace_name including contents and datafiles;
--如果其他表空间中的表有外键等约束关联到了本表空间中的表的字段,就要加上CASCADE CONSTRAINTS
drop tablespace tablespace_name including contents and datafiles cascade constraints;

---转载---

http://www.cnblogs.com/xmaomao/p/3273102.html

原文地址:https://www.cnblogs.com/xiaochina/p/6398853.html