SQL>alter tablespace ...add datafile ...
SQL>alter tablespace ...add tempfile ...
一、增加文件:
SQL>CREATE SMALLFILE TABLESPACE "STAGING" DATAFILE '/u01/app/oracle/oradata/orcl/staging01.dbf' SIZE 3M REUSE NOLOGGING
EXTENT MANAGEMENT LOCAL
SEGMENT SPACE MANAGEMENT AUTO
1、添加文件
SQL>alter tablespace myts01
add datafile 'd:\oracle\product\10.2.0\oradata\orcl\myts03.dbf' size 10M;
2、臨時表空間添加文件
SQL>alter tablespace temp
add tempfile 'd:\oracle\product\10.2.0\oradata\orcl\mytemp.dbf' size 10M;
==============================================================
二、改變數(shù)據(jù)文件的大小
1、設置數(shù)據(jù)文件為自動增長
SQL>create smallfile tablespace myts02
datafile 'd:\oracle\product\10.2.0\oradata\orcl\myts02_1.dbf' size 10M
autoextend on
next 5M
maxsize 50M;
SQL>alter tablespace myts02
add datafile 'd:\oracle\product\10.2.0\oradata\orcl\myts02_2.dbf' size 10M
autoextend on
next 4k
maxsize 40M;
SQL>alter database
datafile 'd:\oracle\product\10.2.0\oradata\orcl\myts01_3.dbf'
autoextend on
next 2M
maxsize 20M;
---取消自動增長---
SQL>alter database
datafile 'd:\oracle\product\10.2.0\oradata\orcl\myts01_3.dbf'
autoextend off;
2、修改數(shù)據(jù)文件的大小
SQL>alter database
datafile 'd:\oracle\product\10.2.0\oradata\orcl\myts01_3.dbf' resize 100M;
三、改變數(shù)據(jù)文件的可用性
1、在archivelog 模式中使數(shù)據(jù)文件(online、offline)
SQL>alter database
datafile 'd:\oracle\product\10.2.0\oradata\orcl\myts02_2.dbf' online;
SQL>alter database
datafile 'd:\oracle\product\10.2.0\oradata\orcl\myts02_2.dbf' offline;
2、在非歸檔(noarchivelog)模式下使數(shù)據(jù)文件offline
SQL>alter database
datafile 'd:\oracle\product\10.2.0\oradata\orcl\myts02_2.dbf' offline drop;
注:這種方法會導致數(shù)據(jù)丟失,一般只用于臨時表空間的臨時數(shù)據(jù)文件
3、修改表空間中所有數(shù)據(jù)文件的可用性
在archivelog模式中影響聯(lián)機或脫機狀態(tài)的語句有:
SQL>alter tablespace ... datafile {online|offline}
SQL>alter tablespace ... tempfile {online|offline}
四、改變數(shù)據(jù)文件的位置和名稱
1、同一表空間數(shù)據(jù)文件的重命名步驟:
SQL>alter tablespace myts02 offline normal;
SQL>alter tablespace myts02
rename datafile 'd:\oracle\product\10.2.0\oradata\orcl\myts02_1.dbf','d:\oracle\product\10.2.0\oradata\orcl\myts02_2.dbf'
to
'd:\oracle\product\10.2.0\oradata\orcl\myts02_01.dbf','d:\oracle\product\10.2.0\oradata\orcl\myts02_02.dbf';
SQL>alter tablespace myts02 online;
2、同一表空間的數(shù)據(jù)文件的重定位
SQL>alter tablespace myts02 offline normal;
SQL>alter tablespace myts02
rename datafile 'd:\oracle\product\10.2.0\oradata\orcl\myts02_01.dbf','d:\oracle\product\10.2.0\oradata\orcl\myts02_02.dbf'
to
'e:\myts02_01.dbf','e:\myts02_02.dbf';
SQL>alter tablespace myts02 online;
3、多個表空間的數(shù)據(jù)文件的重定位和重命名
SQL>alter tablespace myts01 offline normal;
SQL>alter tablespace myts02 offline normal;
SQL>alter database
rename file
'd:\oracle\product\10.2.0\oradata\orcl\myts01_1.dbf','d:\oracle\product\10.2.0\oradata\orcl\myts02_1.dbf'
to
'd:\oracle\product\10.2.0\oradata\orcl\myts01_01.dbf','d:\oracle\product\10.2.0\oradata\orcl\myts02_01.dbf';
SQL>alter tablespace myts01 online;
SQL>alter tablespace myts02 online;
附加:數(shù)據(jù)文件相關的字典
dba_data_files
dba_temp_files
dba_extents
user_extents
dba_free_space
user_free_space
v$datafile
v$datafile_header