Home > Database > Mysql Tutorial > body text

Oracle数据库表空间日常操作

WBOY
Release: 2016-06-07 17:06:18
Original
970 people have browsed it

题记: 作为一Oracle DBA,难免要对数据库表空间做一些操作,这是我在管理数据库时,经常要进行的操作,这里只是记录下来,均是以

题记: 作为一Oracle DBA,难免要对数据库表空间做一些操作,这是我在管理数据库时,经常要进行的操作,这里只是记录下来,均是以例子的方式展现,一为方便自己工作中参考,二为分享给大家!

注意:单个数据文件创建不能超过32G,这是经常被遗忘的。

(1)创建数据表空间:
例1:
CREATE TABLESPACE USERS
    LOGGING
    DATAFILE '/dev/raw/raw6' SIZE 7996M autoextend on
    EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT  AUTO;

例2:
CREATE TABLESPACE MLEE_DATA
    LOGGING
    DATAFILE '/dev/raw/raw1400' SIZE 29996M,
    '/dev/raw/raw1401' SIZE 29996M,
    '/dev/raw/raw1402' SIZE 29996M
    EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT  AUTO;

(2)创建临时表空间:
create temporary tablespace zfmi_temp   tempfile 'D:\oracle\oradata\zfmi\zfmi_temp.dbf'   size 32m   autoextend on   next 32m maxsize 2048m   extent management local;

create temporary tablespace MLEE_TEMP   tempfile '/dev/raw/raw1405' size 9996M  autoextend off  extent management local;

(3)创建UNDO表空间:
CREATE UNDO TABLESPACE UNDOTBS DATAFILE '/opt/oracle/product/9.2.0.4/dbs/undo01.dbf' SIZE 200m   AUTOEXTEND ON NEXT   4096 k   


(4)表空间添加数据文件(undo表空间的扩容方法一样):
alter tablespace tablespacename add datafile ‘/u02/oradata/$ORACLE_SID/datafilename’size128M autoextend on next 2048K maxsize2048M

为临时表空间扩容,,使用下面的语句:
ALTER TABLESPACE &tablespace_name ADD TEMPFILE '/oradata/temp01.dbf' SIZE 2G;

SQL> alter database tempfile '/dev/raw/raw2507' resize 20470M;   --将临时表空间文件增加到约20G大小。

(5)清除临时表空间:
alter tablespace temp shrink space;
这样就将临时表空间中的数据全部清除,此时temp的使用率为0%。


(6)修改表空间名字:
oracle10g以前是不支持修改表空间名的,除非重建;
oracle10g支持在线更改,语法很简单:
 ALTER TABLESPACE tablespacename_old  RENAME TO tablespacename_new;

(7)删除表空间:
drop tablespace RMC_DATA  including contents and datafiles cascade onstraints; 

linux

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!