环境:
SQL> select * from v$version; BANNER ---------------------------------------------------------------- Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bi PL/SQL Release 10.2.0.5.0 - Production CORE 10.2.0.5.0 Production TNS for Linux: Version 10.2.0.5.0 - Production NLSRTL Version 10.2.0.5.0 - Production
数据同步程序报错:
[0521 16:31:25 586 ERROR] [Thread-4] error_log - LogRecord(ID:9104524 dataSourceName:centerdb tableName=BND_INTERESTPAYMENT ) org.springframework.jdbc.BadSqlGrammarException: SqlMapClient operation; bad SQL grammar []; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException: --- The error occurred in sql/tableSQL.xml. --- The error occurred while applying a parameter map. --- Check the deleteTable-InlineParameterMap. --- Check the statement (update failed). --- Cause: java.sql.SQLException: ORA-04045: errors during recompilation/revalidation of CENTER_ADMIN.BIN$qHuI3fcTuU7gQBKseAFC9A==$0 ORA-38301: can not perform DDL/DML over objects in Recycle Bin
检查表 BND_INTERESTPAYMENT,发现缺少 insert 类型触发器 TR_TC_BND_INTERESTPAYMENT_I,
其创建脚本:
CREATE TRIGGER TR_TC_BND_INTERESTPAYMENT_I AFTER INSERT ON BND_INTERESTPAYMENT REFERENCING NEW AS N FOR EACH ROW BEGIN INSERT INTO TABLECHANGELOG (ID,TABLENAME,RECID,ACTIONTYPE,CREATETIME,UPDATETIME) VALUES(SEQ_TC.Nextval, 'BND_INTERESTPAYMENT',:N.ID,1,SYSDATE,SYSDATE); END;
尝试 create or replace trigger 执行脚本,不报错,但 PL/SQL Developer 里没有见到,非常奇怪,
尝试 create trigger,出现报错,提示触发器已存在:
SQL> CREATE TRIGGER TR_TC_BND_INTERESTPAYMENT_I AFTER INSERT ON BND_INTERESTPAYMENT REFERENCING NEW AS N FOR EACH ROW BEGIN INSERT INTO TABLECHANGELOG (ID,TABLENAME,RECID,ACTIONTYPE,CREATETIME,UPDATETIME) VALUES(SEQ_TC.Nextval, 'BND_INTERESTPAYMENT',:N.ID,1,SYSDATE,SYSDATE); END; 2 3 4 5 6 7 8 9 / CREATE TRIGGER TR_TC_BND_INTERESTPAYMENT_I AFTER INSERT ON BND_INTERESTPAYMENT * ERROR at line 1: ORA-04081: trigger 'TR_TC_BND_INTERESTPAYMENT_I' already exists
dba_source 有记录:
SQL> set linesize 200; SQL> select * from dba_source where name = 'TR_TC_BND_INTERESTPAYMENT_I'; OWNER NAME TYPE LINE TEXT ------------------------------ ------------------------------ ---------- ---------- ---------------------------------------------------------------------------------------------------- CENTER_ADMIN TR_TC_BND_INTERESTPAYMENT_I TRIGGER 1 TRIGGER TR_TC_BND_INTERESTPAYMENT_I AFTER INSERT ON BND_INTERESTPAYMENT CENTER_ADMIN TR_TC_BND_INTERESTPAYMENT_I TRIGGER 2 REFERENCING NEW AS N CENTER_ADMIN TR_TC_BND_INTERESTPAYMENT_I TRIGGER 3 FOR EACH ROW CENTER_ADMIN TR_TC_BND_INTERESTPAYMENT_I TRIGGER 4 BEGIN CENTER_ADMIN TR_TC_BND_INTERESTPAYMENT_I TRIGGER 5 INSERT INTO TABLECHANGELOG (ID,TABLENAME,RECID,ACTIONTYPE,CREATETIME,UPDATETIME) CENTER_ADMIN TR_TC_BND_INTERESTPAYMENT_I TRIGGER 6 VALUES(SEQ_TC.Nextval, 'BND_INTERESTPAYMENT',:N.ID,1,SYSDATE,SYSDATE); CENTER_ADMIN TR_TC_BND_INTERESTPAYMENT_I TRIGGER 7 END; 7 rows selected.
dba_triggers 无记录:
SQL> select * from dba_triggers where trigger_name = 'TR_TC_BND_INTERESTPAYMENT_I'; no rows selected
dba_objects 也无记录:
SQL> select * from dba_objects where object_name = 'TR_TC_BND_INTERESTPAYMENT_I'; no rows selected
使用 like 查询 dba_objects 也未找到:
SQL> select trigger_name from dba_triggers where trigger_name like '%TR_TC_BND_INT%' ; TRIGGER_NAME ------------------------------ TR_TC_BND_INTERESTRATE_I TR_TC_BND_INTERESTRATE_D TR_TC_BND_INTERESTRATE_U TR_TC_BND_INTERESTPAYMENT_D TR_TC_BND_INTERESTPAYMENT_U TR_TC_BND_INTERESTPAY_GRP_I TR_TC_BND_INTERESTPAY_GRP_D TR_TC_BND_INTERESTPAY_GRP_U 8 rows selected.
尝试编译,报错:
SQL> alter trigger TR_TC_BND_INTERESTPAYMENT_I compile; alter trigger TR_TC_BND_INTERESTPAYMENT_I compile * ERROR at line 1: ORA-38301: can not perform DDL/DML over objects in Recycle Bin
回收站未有发现(默认不显示触发器):
SQL> show recyclebin; ORIGINAL NAME RECYCLEBIN NAME OBJECT TYPE DROP TIME ---------------- ------------------------------ ------------ ------------------- BFM_BANKFINANCE$ BIN$vEi34vOhcR7gQAB/AQBOjg==$0 TABLE 2012-03-28:14:28:41 OPER BFM_BANKFINANCE_ BIN$1BUrJ3Bdh2ngQAB/AQBvBQ==$0 TABLE 2013-01-25:11:03:16 NEW BFM_BANKFINANCE_ BIN$2zwGOzq09jzgQAB/AQAIjg==$0 TABLE 2013-04-26:11:21:02 NEW$OPER BFM_BANKFINANCE_ BIN$1BUrJ3Blh2ngQAB/AQBvBQ==$0 TABLE 2013-01-25:11:03:17 NEW$OPER BND_BONDHOLDSTRU BIN$2GpwWqUM9lXgQAB/AQA44g==$0 TABLE 2013-03-21:14:27:55 STAT$OPER BND_CASHFLOW$OPE BIN$zby8eUjxjGbgQAB/AQA2mw==$0 TABLE 2012-11-05:17:01:52 R BND_IBSMMQUOTE$O BIN$1He0BtOlALvgQAB/AQBZqw==$0 TABLE 2013-01-30:08:36:38 PER BND_IBSMMQUOTE$O BIN$1Gvklqg/gcPgQAB/AQA/Dg==$0 TABLE 2013-01-29:18:31:13 PER BND_INTERESTPAYM BIN$3TMLA9mGo2HgQAB/AQBywg==$0 TABLE 2013-05-21:11:28:29 ENT$OPER BND_INTERESTPAYM BIN$3TKGz/4FSpDgQAB/AQBw5Q==$0 TABLE 2013-05-21:10:51:52 ENT_GRP BND_INTERESTPAYM BIN$3TKGz/3/SpDgQAB/AQBw5Q==$0 TABLE 2013-05-21:10:51:32 ENT_GRP$OPER BND_NETPURCHASES BIN$2G1lmylkG2zgQAB/AQBBgw==$0 TABLE 2013-03-21:17:59:40 TAT$OPER BND_SECTOR_GES$O BIN$1qs1LLyENo/gQAB/AQBI6g==$0 TABLE 2013-02-27:08:53:52 PER BND_YIELDCURVE BIN$11FgxWESB5/gQAB/AQAIvg==$0 TABLE 2013-03-07:15:08:49 BND_YIELDCURVE$O BIN$11FgxWEgB5/gQAB/AQAIvg==$0 TABLE 2013-03-07:15:09:00 PER BND_YIELDCUVDTL BIN$2Lw1Vu2NJYPgQAB/AQA6UQ==$0 TABLE 2013-03-25:16:01:18 BND_YIELDCUVDTL$ BIN$2Lw1Vu19JYPgQAB/AQA6UQ==$0 TABLE 2013-03-25:16:01:12 OPER BND_YIELDCUVDTL$ BIN$2G3uw6CgPwbgQAB/AQBC3A==$0 TABLE 2013-03-21:18:38:00 OPER BND_YIELDCUVDTL_ BIN$2G8g40lgsdDgQAB/AQBFWA==$0 TABLE 2013-03-21:20:03:37 OLD CAM_BONDPORTFOLI BIN$1He0BtOzALvgQAB/AQBZqw==$0 TABLE 2013-01-30:08:36:42 O$OPER CAM_BONDPORTFOLI BIN$1GvklqhNgcPgQAB/AQA/Dg==$0 TABLE 2013-01-29:18:31:14 O$OPER CAM_ISSUE$OPER BIN$103dHb6PhqvgQAB/AQB8gA==$0 TABLE 2013-03-07:10:57:14 COM_ASSOBUSIOPER BIN$wkP7slUahzXgQAB/AQBuGw==$0 TABLE 2012-06-12:17:20:53 $OPER COM_EMPREMUNERAT BIN$x11Wq67Lp5ngQAB/AQBl0Q==$0 TABLE 2012-08-16:14:59:08 IONPAY COM_EMPREMUNERAT BIN$x11Wq665p5ngQAB/AQBl0Q==$0 TABLE 2012-08-16:14:41:53 IONPAY COM_EMPREMUNERAT BIN$x11Wq67fp5ngQAB/AQBl0Q==$0 TABLE 2012-08-16:14:59:09 IONPAY$OPER COM_FINASPECIALI BIN$0Dsafehb01PgQAB/AQApMQ==$0 TABLE 2012-12-07:10:37:58 NDEXII$OPER COM_SHAREHOLDERR BIN$2dbFRhtZ1ivgQAB/AQBSBg==$0 TABLE 2013-04-08:17:07:47 ESTC$OPER COM_SHAREHOLDERR BIN$2dbDTQ8OUADgQAB/AQBSAA==$0 TABLE 2013-04-08:17:07:15 ESTC$OPER COM_TAXTYPE$OPER BIN$1He0BtPBALvgQAB/AQBZqw==$0 TABLE 2013-01-30:08:36:44 COM_TAXTYPE$OPER BIN$1GvklqhbgcPgQAB/AQA/Dg==$0 TABLE 2013-01-29:18:31:15 CXF BIN$xIT5xAEUKLngQAB/AQBjAQ==$0 TABLE 2012-07-11:09:43:37 CXF0614 BIN$wmljLqGg9/ngQAB/AQBAAA==$0 TABLE 2012-06-14:13:58:23 CXF1 BIN$xQJ/Kb/4b4LgQAB/AQAwIQ==$0 TABLE 2012-07-17:15:30:58 CXF1 BIN$xQJ/Kb/0b4LgQAB/AQAwIQ==$0 TABLE 2012-07-17:15:28:46 CXF1 BIN$wCQj3M3E2rrgQAB/AQA9iw==$0 TABLE 2012-05-16:16:31:05 CXF1 BIN$v6jpj7fdUH/gQAB/AQBr/Q==$0 TABLE 2012-05-10:13:30:06 CXF_1 BIN$wTzChxF+LcjgQAB/AQBuOA==$0 TABLE 2012-05-30:15:18:37 CXF_1 BIN$wAoBQz8rgXDgQAB/AQBtRQ==$0 TABLE 2012-05-15:09:20:15 CXF_1 BIN$v2zkmggWAfLgQAB/AQByyA==$0 TABLE 2012-05-07:13:53:44 CXF_1 BIN$vV9Fa+T8U8PgQAB/AQAksg==$0 TABLE 2012-04-11:10:48:24 CXF_1 BIN$vVEbFz5NhS7gQAB/AQAUTQ==$0 TABLE 2012-04-10:17:54:16 CXF_1 BIN$u72b6LhrlpzgQAB/AQAfeQ==$0 TABLE 2012-03-21:16:30:51 CXF_SL BIN$u5XEXm9NrDrgQAB/AQAebA==$0 TABLE 2012-03-19:17:02:12 CXF_SL BIN$u5XEXm9JrDrgQAB/AQAebA==$0 TABLE 2012-03-19:16:58:51 CXF_TBL BIN$wEx31Vy1XIXgQAB/AQAdLg==$0 TABLE 2012-05-18:16:37:52 FND_BENCHMARK$OP BIN$1He0BtPOALvgQAB/AQBZqw==$0 TABLE 2013-01-30:08:36:44 ER FND_BENCHMARK$OP BIN$1GvklqhpgcPgQAB/AQA/Dg==$0 TABLE 2013-01-29:18:31:15 ER FND_MANAGERSECYI BIN$wjzzju8/pjDgQAB/AQBB1w==$0 TABLE 2012-06-12:08:57:32 ELD$OPER FUD_TRUSTPLANINF BIN$1OM0eFhxjpDgQAB/AQByew==$0 TABLE 2013-02-04:16:51:55 O FUD_TRUSTPLANINF BIN$1p0zxodJJ8XgQAB/AQArqw==$0 TABLE 2013-02-26:16:11:38 O$OPER FUD_TRUSTPLANINF BIN$1p0zxoc8J8XgQAB/AQArqw==$0 TABLE 2013-02-26:16:11:19 O$OPER FUD_TRUSTPLANINF BIN$1ORbhHj1J0DgQAB/AQAECA==$0 TABLE 2013-02-04:18:14:24 O$OPER FUD_TRUSTPLANINF BIN$1OM0eFh+jpDgQAB/AQByew==$0 TABLE 2013-02-04:16:52:00 O$OPER FUD_TRUSTPLANINF BIN$vVFFZ3bdBi7gQAB/AQAZHQ==$0 TABLE 2012-04-10:18:06:06 O$OPER INS_BASICINFO BIN$wmcXkozr2s/gQAB/AQAUqQ==$0 TABLE 2012-06-14:11:14:05 INS_BASICINFO$OP BIN$wmcXkoz12s/gQAB/AQAUqQ==$0 TABLE 2012-06-14:11:15:45 ER LOG_DDL_ALTERONO BIN$u6ZqY8tljYngQAB/AQBgKQ==$0 TABLE 2012-03-20:12:50:36 PER MMD_FOREIGNEXCHA BIN$1He0BtPbALvgQAB/AQBZqw==$0 TABLE 2013-01-30:08:36:44 NGE$OPER MMD_FOREIGNEXCHA BIN$1Gvklqh2gcPgQAB/AQA/Dg==$0 TABLE 2013-01-29:18:31:15 NGE$OPER MOD_OBJSHOWPRE_N BIN$191sFiolHm7gQAB/AQAJ6g==$0 TABLE 2013-03-14:14:13:33 EW$OPER RPT_FORECASTRATI BIN$zD6ICFFDXD3gQAB/AQAL/w==$0 TABLE 2012-10-17:17:06:26 NG$OPER RPT_FORECASTRATI BIN$zD6ICFE2XD3gQAB/AQAL/w==$0 TABLE 2012-10-17:17:02:34 NG$OPER SERVERLIST BIN$w4W7Yup8ivbgQAB/AQBMww==$0 TABLE 2012-06-28:17:12:34 SERVERLIST BIN$v5i238kULDfgQAB/AQAM3w==$0 TABLE 2012-05-09:18:10:36 SERVERLIST_B0411 BIN$vV9Fa+T4U8PgQAB/AQAksg==$0 TABLE 2012-04-11:10:48:16 SERVERLIST_B0412 BIN$12UN0AmSphbgQAB/AQA8bQ==$0 TABLE 2013-03-08:14:37:15 SERVERLIST_B1204 BIN$12UN0AmWphbgQAB/AQA8bQ==$0 TABLE 2013-03-08:14:37:16 18 SERVERLIST_B1205 BIN$12UN0AmaphbgQAB/AQA8bQ==$0 TABLE 2013-03-08:14:37:17 03 SERVERLIST_B1205 BIN$12UN0AmephbgQAB/AQA8bQ==$0 TABLE 2013-03-08:14:37:17 08 SERVERLIST_B1205 BIN$12UN0AmiphbgQAB/AQA8bQ==$0 TABLE 2013-03-08:14:37:18 09 SERVERLIST_B1205 BIN$12UN0AmmphbgQAB/AQA8bQ==$0 TABLE 2013-03-08:14:37:18 10 SERVERLIST_B1205 BIN$12UN0AmqphbgQAB/AQA8bQ==$0 TABLE 2013-03-08:14:37:19 11 SERVERLIST_B1205 BIN$12UN0AmuphbgQAB/AQA8bQ==$0 TABLE 2013-03-08:14:37:19 15 SERVERLIST_B1205 BIN$12UN0AmyphbgQAB/AQA8bQ==$0 TABLE 2013-03-08:14:37:20 16 SERVERLIST_B2012 BIN$12UN0Am2phbgQAB/AQA8bQ==$0 TABLE 2013-03-08:14:37:20 0507 SERVERLIST_B2012 BIN$12UN0Am6phbgQAB/AQA8bQ==$0 TABLE 2013-03-08:14:37:21 0518 SERVERLIST_B2012 BIN$12UN0Am+phbgQAB/AQA8bQ==$0 TABLE 2013-03-08:14:37:21 0522 SERVERLIST_B2012 BIN$12UN0AnCphbgQAB/AQA8bQ==$0 TABLE 2013-03-08:14:37:21 0530 SERVERLIST_B2012 BIN$12UN0AnGphbgQAB/AQA8bQ==$0 TABLE 2013-03-08:14:37:22 0606 SERVERLIST_B2012 BIN$12UN0AnKphbgQAB/AQA8bQ==$0 TABLE 2013-03-08:14:37:22 0606_2 SERVERLIST_B2012 BIN$12UN0AnOphbgQAB/AQA8bQ==$0 TABLE 2013-03-08:14:37:23 0614 SERVERLIST_B2012 BIN$12UN0AnSphbgQAB/AQA8bQ==$0 TABLE 2013-03-08:14:37:23 0619 SERVERLIST_B2012 BIN$12UN0AnWphbgQAB/AQA8bQ==$0 TABLE 2013-03-08:14:37:23 0626 SERVERLIST_B2012 BIN$12UN0AnaphbgQAB/AQA8bQ==$0 TABLE 2013-03-08:14:37:24 0628 SERVERLIST_B2012 BIN$12UN0AnephbgQAB/AQA8bQ==$0 TABLE 2013-03-08:14:37:24 0628_120 SERVERLIST_B2012 BIN$12UN0AniphbgQAB/AQA8bQ==$0 TABLE 2013-03-08:14:37:25 0629 SERVERLIST_B2012 BIN$12UN0AnmphbgQAB/AQA8bQ==$0 TABLE 2013-03-08:14:37:25 0706 SERVERLIST_B2012 BIN$12UN0AnqphbgQAB/AQA8bQ==$0 TABLE 2013-03-08:14:37:26 0711 SERVERLIST_B2012 BIN$12UN0AnuphbgQAB/AQA8bQ==$0 TABLE 2013-03-08:14:37:26 0717 SERVERLIST_B2012 BIN$12UN0AnyphbgQAB/AQA8bQ==$0 TABLE 2013-03-08:14:37:26 0724 SERVERLIST_B2012 BIN$12UN0An2phbgQAB/AQA8bQ==$0 TABLE 2013-03-08:14:37:27 0815 SERVERLIST_B2012 BIN$12UN0An6phbgQAB/AQA8bQ==$0 TABLE 2013-03-08:14:37:27 0817 SERVERLIST_B2013 BIN$12UN0An+phbgQAB/AQA8bQ==$0 TABLE 2013-03-08:14:37:28 0218 STK_MONEYFLOWLIS BIN$vCMBIRwP/zvgQAB/AQAqrg==$0 TABLE 2012-03-26:17:29:01 TS$OPER TT BIN$tib5dDnmWwTgQBKseAF6Gg==$0 TABLE 2012-01-10:14:09:06 TT BIN$tib5dDniWwTgQBKseAF6Gg==$0 TABLE 2012-01-10:13:42:02
尝试 drop 该触发器,并 purge 回收站,然后 create trigger,成功:
SQL> drop trigger TR_TC_BND_INTERESTPAYMENT_I 2 / Trigger dropped. SQL> purge recyclebin -- 这一步似乎不是必须的 2 / Recyclebin purged. SQL> create trigger ...
但是同步程序报错依旧,select * from recyclebin 的时候,
可以看到 original_name = 'BIN$qHuI3fcTuU7gQBKseAFC9A==$0' 的记录,是 trigger,但已经是两年前的,详细的操作不清楚;
直接执行 drop,成功:
drop trigger "BIN$qHuI3fcTuU7gQBKseAFC9A==$0";
同步程序不再报错。
------------------------------------------------------------------
尝试模拟问题,未能成功,未知:
1、不知道为何出现 create trigger TR_TC_BND_INTERESTPAYMENT_I 不能创建?
2、不知道为何会编译回收站的这个 "BIN$qHuI3fcTuU7gQBKseAFC9A==$0” trigger?