Oracle更改表空间文件位置
Oracle更改表空间文件位置
测试全步骤:
//创建临时表空间 [sql] create temporary tablespace test_temp tempfile 'D:\oracle\product\10.2.0\oradata\orcl\test_temp01.dbf' size 32m autoextend on next 32m maxsize 2048m extent management local; //创建数据表空间 [sql] create tablespace test_data logging datafile 'D:\oracle\product\10.2.0\oradata\orcl\test_data01.dbf' size 32m autoextend on next 32m maxsize 2048m extent management local; //创建用户并指定表空间 [sql] create user test01 identified by test01 default tablespace test_data temporary tablespace test_temp; //给用户授予权限 [sql] grant connect,resource to test01; //创建测试表及数据 [sql] conn test01/test01; [sql] create table tab_test01 ( a VARCHAR2(6), b VARCHAR2(30), c VARCHAR2(80), d NUMBER(4) ); [sql] insert into tab_test01 (a,b,c,d) values ('1','2','3',4); commit; select * from tab_test01; //开始迁移 [plain] SET ORACLE_SID=DB10G SQLPLUS /NOLOG CONN SYS/SYS AS SYSDBA; SHUTDOWN IMMEDIATE; (文件操作)复制(移动)数据文件至新路径 //更改路径设置 [plain] STARTUP MOUNT; ALTER DATABASE rename FILE 'D:\oracle\product\10.2.0\oradata\orcl\test_data01.dbf' to 'D:\TEST_DATA01.DBF'; ALTER DATABASE OPEN; //测试:往用户里面导入新数据;查看是否在新位置文件增加大小 imp test01/test01@orcl file=d:\cust.dmp ignore=y full=y //测试通过;过程完成。 //删除本次操作的案例数据 //删除用户 [sql] drop user test01 cascade; //删除表空间 [sql] DROP TABLESPACE test_temp INCLUDING CONTENTS AND DATAFILES; DROP TABLESPACE test_data INCLUDING CONTENTS AND DATAFILES;