drop table test1;
create table test1 tablespace users as select object_id t1,object_name t2 from
dba_objects where object_id is not null;
alter table test1 add primary key(t1);
exec dbms_stats.gather_table_stats('MACLEAN','TEST1',cascade=>TRUE);
create database link maclean connect to maclean identified by maclean using
'G10R21';
Database link created.
以上源端数据库版本为 11.2.0.3 , 源表结构为 test1(t1 number primary key,t2 varchar2(128),
透过 dblink 链接到版本为 10.2.0.1 的目标端
conn maclean/maclean
SQL> select * from v$version
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
create table test2 tablespace users as select object_id t1,object_name t2
from dba_objects where object_id is not null;
alter table test2 add primary key(t1);
exec dbms_stats.gather_table_stats('MACLEAN','TEST2',cascade=>TRUE);
目标端版本为 10.2.0.1 , 表结构为 test2(t1 number primary key,t2 varchar2(128))。
注意这里 2 张表上均必须有相同的主键索引或者伪主键索引(pseudoprimary key 伪主键要求是
唯一键且所有的成员列均是非空 NOT NULL)。