测试过程:
1)在solaris上的数据库用户esm_symbian1上创建一个数据库连接
2)在esm_symbian1用户创建database link 命名为symbian
3)在远程的数据库用户mobile中创建表 send_mail
4)在本地的数据库用户esm_symbian1中创建表 send_mail
5)在本地esm_symbian1创建指向远程数据库用户mobile中send_mail的同义词create synonym SEND_MAIL_M for SEND_MAIL@symbian;
send_mail表结构如下:
SQL> desc send_mail;
Name Type Nullable Default Comments
--------------- -------------- -------- ------- --------
SEND_MAIL_CODE NUMBER
EMPLOYEE_CODE NUMBER Y
SUBJECT VARCHAR2(300) Y
MESSAGE VARCHAR2(3000) Y
SEND_DATE DATE Y
SAVE_DATE DATE Y
REFFERENCE_CODE NUMBER Y
STATUS_DISP_FLG NUMBER Y
DEPART_CODE NUMBER Y
测试一:
用如下语句对本地表进行insert 测试:
INSERT INTO SEND_MAIL (SEND_MAIL_CODE,EMPLOYEE_CODE,SUBJECT,MESSAGE,SEND_DATE,REFFERENCE_CODE,STATUS_DISP_FLG,DEPART_CODE)
SELECT SEND_MAIL_CODE,EMPLOYEE_CODE,SUBJECT,MESSAGE,SEND_DATE,REFFERENCE_CODE,STATUS_DISP_FLG,DEPART_CODE
FROM SEND_MAIL WHERE SEND_MAIL.SEND_DATE>to_timestamp('2006-04-13 17:58:55.759','syyyy-mm-dd hh24:mi:ss.ff')
错误:
ORA-00001: 违反唯一约束条件 (ESM_SYMBIAN5.SYS_C0073461)
着说明本地插入是正常的,只是本地有相同的数据,才出现这个错误
测试二:
通过同义词用同样的语句向远程表进行插入
INSERT INTO SEND_MAIL_M (SEND_MAIL_CODE,EMPLOYEE_CODE,SUBJECT,MESSAGE,SEND_DATE,REFFERENCE_CODE,STATUS_DISP_FLG,DEPART_CODE)
SELECT SEND_MAIL_CODE,EMPLOYEE_CODE,SUBJECT,MESSAGE,SEND_DATE,REFFERENCE_CODE,STATUS_DISP_FLG,DEPART_CODE
FROM SEND_MAIL_M WHERE SEND_MAIL_M.SEND_DATE>to_timestamp('2006-04-13 17:58:55.759','syyyy-mm-dd hh24:mi:ss.ff')
0 rows inserted
这个说明对远程的操作也是正常的
测试三:
(这条语句是把本地的查询结果作为insert语句的value值 通过同义词插入到远程数据库中去)
INSERT INTO SEND_MAIL_M (SEND_MAIL_CODE,EMPLOYEE_CODE,SUBJECT,MESSAGE,SEND_DATE,REFFERENCE_CODE,STATUS_DISP_FLG,DEPART_CODE)
SELECT SEND_MAIL_CODE,EMPLOYEE_CODE,SUBJECT,MESSAGE,SEND_DATE,REFFERENCE_CODE,STATUS_DISP_FLG,DEPART_CODE
FROM SEND_MAIL WHERE SEND_MAIL.SEND_DATE>to_timestamp('2006-04-13 17:58:55.759','syyyy-mm-dd hh24:mi:ss.ff')
ORA-02055: 分布式更新操作失效;要求回退
ORA-02068: 以下严重错误源于SYMBIAN
ORA-03113: 通信通道的文件结束