drop物化檢視log表導致insert、delete、update報ORA-00942
之前基於emp表測試物化檢視建立了 物化檢視log表,測試完成後清理不用的表 直接drop table 物化檢視log表,過段時間再用emp表的時候發現:
select emp正常,但是insert、delete、update就報 ORA-00942: table or view does not exist
下面重現這個問題:
#建立物化檢視log表在emp上
SQL> create materialized view log on emp with rowid;
Materialized view log created.
SQL> select * from tab;
TNAME TABTYPE CLUSTERID
------------------------------ ------- ----------
BONUS TABLE
DEPT TABLE
EMP TABLE
MLOG$_EMP TABLE
SALGRADE TABLE
#直接刪除log表
SQL> drop table MLOG$_EMP purge;
Table dropped.
SQL> select * from tab;
TNAME TABTYPE CLUSTERID
------------------------------ ------- ----------
BONUS TABLE
DEPT TABLE
EMP TABLE
SALGRADE TABLE
#進行select、insert、update、delete操作:
SQL> select count(*) from emp;
COUNT(*)
----------
14
#發現insert、delete、update報ORA-00942
SQL> update emp set empno=empno+1;
update emp set empno=empno+1
*
ERROR at line 1:
ORA-00942: table or view does not exist
SQL> delete emp where empno=7379;
delete emp where empno=7379
*
ERROR at line 1:
ORA-00942: table or view does not exist
SQL> insert into emp(empno) values(1);
insert into emp(empno) values(1)
*
ERROR at line 1:
ORA-00942: table or view does not exist
解決方法:
#查出dba_mview_logs中存在,而的log表不存在的物件
select 'drop materialized view log on '||mvl.log_owner||'.'||mvl.master||';' cmd from dba_mview_logs mvl where not exists ( select table_name from dba_tables tab where tab.owner = mvl.log_owner and tab.table_name = mvl.log_table ) ;
CMD
--------------------------------------------------------------------------------
drop materialized view log on SCOTT.EMP;
#執行正確的刪除 materialized view log 語句
SQL> drop materialized view log on SCOTT.EMP;
Materialized view log dropped.
#問題解決
SQL> delete emp where empno=7379;
1 row deleted.
SQL> rollback;
Rollback complete.
參考mos文章:
select emp正常,但是insert、delete、update就報 ORA-00942: table or view does not exist
下面重現這個問題:
#建立物化檢視log表在emp上
SQL> create materialized view log on emp with rowid;
Materialized view log created.
SQL> select * from tab;
TNAME TABTYPE CLUSTERID
------------------------------ ------- ----------
BONUS TABLE
DEPT TABLE
EMP TABLE
MLOG$_EMP TABLE
SALGRADE TABLE
#直接刪除log表
SQL> drop table MLOG$_EMP purge;
Table dropped.
SQL> select * from tab;
TNAME TABTYPE CLUSTERID
------------------------------ ------- ----------
BONUS TABLE
DEPT TABLE
EMP TABLE
SALGRADE TABLE
#進行select、insert、update、delete操作:
SQL> select count(*) from emp;
COUNT(*)
----------
14
#發現insert、delete、update報ORA-00942
SQL> update emp set empno=empno+1;
update emp set empno=empno+1
*
ERROR at line 1:
ORA-00942: table or view does not exist
SQL> delete emp where empno=7379;
delete emp where empno=7379
*
ERROR at line 1:
ORA-00942: table or view does not exist
SQL> insert into emp(empno) values(1);
insert into emp(empno) values(1)
*
ERROR at line 1:
ORA-00942: table or view does not exist
解決方法:
#查出dba_mview_logs中存在,而的log表不存在的物件
select 'drop materialized view log on '||mvl.log_owner||'.'||mvl.master||';' cmd from dba_mview_logs mvl where not exists ( select table_name from dba_tables tab where tab.owner = mvl.log_owner and tab.table_name = mvl.log_table ) ;
CMD
--------------------------------------------------------------------------------
drop materialized view log on SCOTT.EMP;
#執行正確的刪除 materialized view log 語句
SQL> drop materialized view log on SCOTT.EMP;
Materialized view log dropped.
#問題解決
SQL> delete emp where empno=7379;
1 row deleted.
SQL> rollback;
Rollback complete.
參考mos文章:
|
|
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/27000195/viewspace-1400038/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- SQLite語句(二):INSERT DELETE UPDATE SELECTSQLitedelete
- DBeaver如何生成select,update,delete,insert語句delete
- sql server 帶有OUTPUT的INSERT,DELETE,UPDATESQLServerdelete
- Thinkphp 3.2.3 parseWhere設計缺陷導致update/delete注入 分析PHPdelete
- ORACLE RAC叢集大範圍delete大表與insert&update同時執行導致活動會話數飆升Oracledelete會話
- KunlunDB功能之insert/update/delete...returning語句delete
- 利用insert,update和delete注入獲取資料delete
- mysql 在delete、insert、update 時,page的變化MySqldelete
- 物化檢視
- 輕量ORM-SqlRepoEx (四)INSERT、UPDATE、DELETE 語句ORMSQLdelete
- 物化檢視(zt)
- java-Mybatis XML 對映器(select,insert, update 和 delete)JavaMyBatisXMLdelete
- SQL Server的Merge —— 一步實現 insert,update,deleteSQLServerdelete
- calcite物化檢視詳解
- Oracle普通檢視和物化檢視的區別Oracle
- 資料庫的物化檢視資料庫
- 物化檢視分割槽實驗
- 【MVIEW】Oracle通過物化檢視同步表資料及簡介ViewOracle
- mssql sqlserver update delete表別名用法簡介SQLServerdelete
- Sqlserver update\delete用inner join關聯,會update\delete關鍵字後面的表關聯到的行SQLServerdelete
- ClickHouse 物化檢視學習總結
- 物化檢視幾個知識點
- MySQL死鎖案例分析一(先delete,再insert,導致死鎖)MySqldelete
- sql:delete if exists還是drop if exists?SQLdelete
- MySQL Insert資料量過大導致報錯 MySQL server has gone awayMySqlServerGo
- ClickHouse 效能優化?試試物化檢視優化
- ClickHouse效能優化?試試物化檢視優化
- Oracle物化檢視的建立及使用(二)Oracle
- Oracle物化檢視的建立及使用(一)Oracle
- MyBatis(五) insert、update、delete 、主鍵回填、返回matched行數和affected行數、引數配置#{},${}MyBatisdelete
- mysql的新建索引會導致insert被lockedMySql索引
- 380. Insert Delete GetRandom O (1)deleterandom
- 用ASP.NET Core 2.0 建立規範的 REST API -- DELETE, UPDATE, PATCH 和 LogASP.NETRESTAPIdelete
- ORA-01623: log is current log for thread - cannot dropthread
- StarRocks 物化檢視重新整理流程和原理
- StarRocks 物化檢視重新整理流程及原理
- 基於ROWID更新的物化檢視測試
- 物化檢視如何快速完成資料聚合操作?
- Sqlserver、oracle中Merge的使用方法,一個merge語句搞定多個Insert,Update,Delete操作SQLServerOracledelete