首页 > 代码库 > 【练习】数据文件的迁移

【练习】数据文件的迁移

1.查看表空间对应得数据文件

SQL> select FILE_NAME,TABLESPACE_NAME from dba_data_files;

FILE_NAME                                          TABLESPACE_NAME
-------------------------------------------------- ---------------
/u01/app/oracle/oradata/ORA11GR2/example01.dbf     EXAMPLE
/u01/app/oracle/oradata/ORA11GR2/users01.dbf       USERS
/u01/app/oracle/oradata/ORA11GR2/undotbs01.dbf     UNDOTBS1
/u01/app/oracle/oradata/ORA11GR2/sysaux01.dbf      SYSAUX
/u01/app/oracle/oradata/ORA11GR2/system01.dbf      SYSTEM
/u01/app/oracle/oradata/ORA11GR2/tbs1.dbf          TBS1
/u01/app/oracle/oradata/ORA11GR2/tbs2.dbf          TBS1

7 rows selected.

2.将表空间offline

SQL> alter tablespace users offline;

Tablespace altered.

SQL> select TABLESPACE_NAME,STATUS from dba_tablespaces;

TABLESPACE_NAME                STATUS
------------------------------ ---------
SYSTEM                         ONLINE
SYSAUX                         ONLINE
UNDOTBS1                       ONLINE
TEMP                           ONLINE
USERS                          OFFLINE
EXAMPLE                        ONLINE
TBS1                           ONLINE

3.拷贝

[oracle@host02 ~]$ cp /u01/app/oracle/oradata/ORA11GR2/users01.dbf /u01/app/oracle/users01.dbf

4.更新控制文件中的信息

SQL> alter database rename file /u01/app/oracle/oradata/ORA11GR2/users01.dbf to /u01/app/oracle/users01.dbf;

Database altered.

5.将表空间online

SQL> alter tablespace users online;

Tablespace altered.

 

【练习】数据文件的迁移