数据库的数据迁移一般直接使用PLSQL客户端在Tools里选择Export Tables导出一个dmp文件,在另一个数据库建用户和表空间,然后把这个文件导入即可。
有时候会遇到导入的表空间发生变化的情况,比如我们这次迁移就遇到了,以下是我查找到的方法 move tablespace,很好用而且我们迁移成功了。
需要注意的是:Move命令不支持Long型字段。
1、移动表到指定表空间
其中前面带“Your”的地方是需要分别更换为实际表名和表空间名的。
2、可能用到的其他SQL语句
当然还有其他的执行操作,我们没有用到所以在这也不贴了
有时候会遇到导入的表空间发生变化的情况,比如我们这次迁移就遇到了,以下是我查找到的方法 move tablespace,很好用而且我们迁移成功了。
需要注意的是:Move命令不支持Long型字段。
1、移动表到指定表空间
alter table Your_Table_Name move tablespace Your_New_TableSpace_Name;
其中前面带“Your”的地方是需要分别更换为实际表名和表空间名的。
2、可能用到的其他SQL语句
查找数据库文件对应的File_ID
select * from dba_data_files;
查询当前表空间中的所有表
select distinct segment_name from dba_extents where segment_type='TABLE' and file_id=14;
查询当前表空间中的所有索引
select distinct segment_name from dba_extents where segment_type='INDEX' and file_id=14;
如果有分区表,则查询当前表空间中的所有的分区表
select distinct segment_name from dba_extents where segment_type='TABLE PARTITION' and file_id=14;
查询当前表空间中的所有分区表的索引
select distinct segment_name from dba_extents where segment_type='INDEX PARTITION' and file_id=14;
移动表到指定表空间
alter table Tbl_Name move tablespace New_TableSpaceName;
重建表的索引
alter index Index_Name rebuild tablespace New_TableSpaceName;
移动BLOB、CLOB的字段到指定表空间
alter table Tbl_Name move lob(BLOB1,BLOB2,BLOB3,......) store as (tablespace New_TableSpaceName);
移动BLOB、CLOB的字段语法
alter table table_name move [tablespace tbs_name] lob(lob_field1,lob_field2) store as (tablespace new_tbs_name);
如果LOB字段在分区表中,则增加partition关键字,如
alter table table_name move [partition partname] [tablespace tbs_name] lob(field) store as (tablespace new_tbs_name);
当然还有其他的执行操作,我们没有用到所以在这也不贴了