利用外部表实现数据的迁移
数据移动例子
使用oracle_datapump创建外部表来迁移数据
1.在源数据库中创建目录;
create directory dir_dump as '/home/oracle';
grant read,write on directory dir_dump to public;
2.创建外部表并卸载数据;
create table test_t5 organization external
(type oracle_datapump
default directory dir_dump
location ('t5_part1.dat','t5_part2.dat'))
parallel 2
as select ower,table_name,tablespace_name from dba_tables;
--define _editor=vi
--ed (设置vi,编辑)
select count(*) from test_t5;
strings t5_part1.dat|more
--检测数据
3.将上一步的数据文件,拷贝到远程的数据库目录;
scp…… --远程拷贝
mkdir -p dat
cp t5_p* dat/
cd dat/
4.在目标数据库上使用我们拷贝过来的数据文件创建外部表;
create directory dir_dump2 as '/home/oracle/dat';
grant read,write on directory dir_dump2 to public;
create tbale t_external(
owner varchar2(100),
table_name varchar2(100),
tablespace_name varchar2(100))
organization external(
type oracle_datapump
default directory dir_dump2
loaction ('t5_part1.dat','t5_part2.dat'));
select count(*) from t_external;
--查看外部表