您的当前位置:首页正文

Oracle教程:移动所有数据文件

2020-11-09 来源:独旅网

Oracle教程:移动所有数据文件,最近在一个开发库上存在硬盘空间紧张的问题,新添加了一块盘,准备把所有的数据文件挪到新盘上。

如题,,最近在一个开发库上存在硬盘空间紧张的问题,新添加了一块盘,准备把所有的数据文件挪到新盘上。
首先列出需要移动的数据文件,数据文件隶属于表空间,我们从表空间用途可以如下分门别类:
控制文件
System表空间
undo表空间
temporary表空间
redo日志文件
user_data表空间

SQL> select tablespace_name from dba_tablespaces;

TABLESPACE_NAME
------------------------------
SYSTEM
UNDOTBS1
SYSAUX
TEMP
USERS
GTLIONS
GTLIONSTMP

SQL> select file_name,file_id,tablespace_name from dba_data_Files;
FILE_NAME FILE_ID TABLESPACE_NAME
-------------------------------------------------- ---------- ------------------------------
/u01/Oracle/10g/oradata/gt10g/users01.dbf 4 USERS
/u01/oracle/10g/oradata/gt10g/sysaux01.dbf 3 SYSAUX
/u01/oracle/10g/oradata/gt10g/undotbs01.dbf 2 UNDOTBS1
/u01/oracle/10g/oradata/gt10g/system01.dbf 1 SYSTEM
/u01/oracle/10g/oradata/gt10g/gtlions01.ora 5 GTLIONS

SQL> select file_name,file_id,tablespace_name from dba_temp_Files;

FILE_NAME FILE_ID TABLESPACE_NAME
-------------------------------------------------- ---------- ------------------------------
/u01/oracle/10g/oradata/gt10g/temp01.dbf 1 TEMP
/u01/oracle/10g/oradata/gt10g/gtlionstmp01.ora 2 GTLIONSTMP

SQL> select name from v$controlfile;

NAME
------------------------------------------------------------------------------------------------------------------------------------------------------
/u01/oracle/10g/oradata/gt10g/control01.ctl
/u01/oracle/10g/oradata/gt10g/control02.ctl
/u01/oracle/10g/oradata/gt10g/control03.ctl

SQL> select member from v$logfile;

MEMBER
------------------------------------------------------------------------------------------------------------------------------------------------------
/u01/oracle/10g/oradata/gt10g/redo03.log
/u01/oracle/10g/oradata/gt10g/redo02.log
/u01/oracle/10g/oradata/gt10g/redo01.log

针对undo表空间,我们可以在打开数据的状态下直接操作:
SQL> create undo tablespace undotbs2 datafile '/u01/oracle/10g/oradata/gt10gnew/undotbs01.dbf' size 20m autoextend on;

Tablespace created.

SQL> show parameter undo_tablespace;

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
undo_tablespace string UNDOTBS1
SQL> alter system set undo_tablespace='undotbs2';

System altered.

SQL> show parameter undo_tablespace;

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
undo_tablespace string undotbs2
SQL> drop tablespace undotbs1;

Tablespace dropped.

linux

显示全文