当前位置:网站首页> 大表delete删数据导致数据库异常解决
大表delete删数据导致数据库异常解决
2022-07-07 13:11:00 【1024问】
一、问题描述
二、查看数据库情况
三、提出方案
四、执行过程
一、问题描述早上正在上班路上,群里客户说,有一张24G的大表,delete删了26小时还没有跑完,目前进程还在跑让帮忙处理下,停止当前进程,并保留对应条件的数据,多余数据删掉。
二、查看数据库情况1.未开归档
2.UNDO表空间爆满
三、提出方案1.经过沟通,该表为测试数据表,目前没有在使用;
于是打算rename该表,通过ctas的方式去将需要的数据捞出来,重建索引和相关约束。
2.存在一个问题:delete进程已经执行了26小时,如果kill进程,必然会导致undo回滚,回滚默认开启并行会导致数据库和系统负载很高,于是需要提前处理下,设置参数_fast_start_parallel_rollback_关掉UNDO并行。
--查看回滚参数设置,是否是默认并行SQL> show parameter fast_start_parallel_rollbackNAME TYPE VALUE------------------------------------ ----------- ------------------------------fast_start_parallel_rollback string LOW--LOW 代表 开启CPU*2并行--设置spfile取消并行SQL> alter system set fast_start_parallel_rollback=false;System altered.四、执行过程1.备份保留 表创建语句。
2.记录当前无效对象。
SELECT d.OWNER ,d.OBJECT_NAME ,d.OBJECT_TYPE ,d.statusFROM dba_objects dWHERE d.status = 'INVALID' AND d.owner = '**';3.查看delete进程pid,系统级kill掉。
--查询SID, SERIAL#select s.SQL_TEXT, se.SID, se.SERIAL# from v$session se, v$sql s where s.sql_id = se.SQL_ID and username = '**' and status = 'ACTIVE' and s.SQL_TEXT like '%delete * from *****%';--数据库级kill进程alter system kill session '2953,31083';报错
ERROR at line 1:
ORA-00031: session marked for kill
--系统级 kill进程
select spid, osuser, s.program
from v$session s,v$process p
where s.paddr=p.addr and s.sid=2953;
kill -9 105257
4.观察undo回滚情况
--查看等待事件select inst_id,event,count(*) from gv$session a where a.status='ACTIVE' and not (a.type = 'BACKGROUND' and a.state='WAITING' and a.wait_class='Idle') group by inst_id,event order by a.inst_id,count(*) desc;---------------------------------------------------1wait for a undo record611resmgr:cpu quantum291enq: RO - fast object reuse221enq: CR - block range reuse ckpt201free buffer waits17--查看当前数据回滚情况alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';select usn, state, undoblockstotal "Total", undoblocksdone "Done", undoblockstotal - undoblocksdone "ToDo", decode(cputime, 0, 'unknown', sysdate + (((undoblockstotal - undoblocksdone) / (undoblocksdone / cputime)) / 86400)) "Estimated time to complete" from v$fast_start_transactions where state = 'RECOVERING';---------------------------------------------------83RECOVERING9026713455902625826-4月 -215.观察系统负载,IO负载,内存使用情况
6.等待回滚完成,持续时间较久。
7.回滚成功后,rename 原表。
rename table to table_20210410;8.CTAS将需要的数据捞到新表(原来的表名)中。
create table USER.TABLEnologging parallel 8tablespace TBSas select /*+parallel(TABLE,'8')*/ * from USER.TABLE_20210410where *** like '******%';--取消并行alter table USER.TABLE noparallel;--开启loggingalter table USER.TABLE logging;9.rename索引,并重建索引。
alter index USER.INDEX1 rename to INDEX1_20210410;--重建索引create index USER.INDEX1 on USER.TABLE (***) tablespace TBS parallel 8;--取消并行alter index USER.INDEX1 noparallel;10.创建约束,授权。
11.比对无效对象,数据是否一致
12.drop掉rename的表。
drop table USER.TABLE_20210410 cascade;以上就是大表delete删数据导致数据库异常解决的详细内容,更多关于delete删数据数据库异常的资料请关注软件开发网其它相关文章!
边栏推荐
- [机缘参悟-40]:方向、规则、选择、努力、公平、认知、能力、行动,读3GPP 6G白皮书的五层感悟
- 防火墙基础之服务器区的防护策略
- Infinite innovation in cloud "vision" | the 2022 Alibaba cloud live summit was officially launched
- Jetson AGX Orin CANFD 使用
- 一个需求温习到的所有知识,h5的表单被键盘遮挡,事件代理,事件委托
- Bye, Dachang! I'm going to the factory today
- Ffmpeg --- image processing
- CTFshow,信息搜集:web9
- CTFshow,信息搜集:web3
- Niuke real problem programming - day18
猜你喜欢

CTFshow,信息搜集:web8

【OBS】RTMPSockBuf_ Fill, remote host closed connection.

What is data leakage

Ctfshow, information collection: web14

Win10 or win11 taskbar, automatically hidden and transparent

In the field of software engineering, we have been doing scientific research for ten years!

写一篇万字长文《CAS自旋锁》送杰伦的新专辑登顶热榜

Unity's ASE realizes cartoon flame

什么是数据泄露

CTFshow,信息搜集:web12
随机推荐
How bad can a programmer be? Nima, they are all talents
Find your own value
Pinduoduo lost the lawsuit, and the case of bargain price difference of 0.9% was sentenced; Wechat internal test, the same mobile phone number can register two account functions; 2022 fields Awards an
用于增强压缩视频质量的可变形卷积密集网络
什么是数据泄露
Ctfshow, information collection: web8
Niuke real problem programming - day18
知否|两大风控最重要指标与客群好坏的关系分析
[target detection] yolov5 Runtong voc2007 data set
Qu'est - ce qu'une violation de données
【深度学习】语义分割实验:Unet网络/MSRC2数据集
Briefly describe the working principle of kept
[deep learning] image hyperspectral experiment: srcnn/fsrcnn
CTFshow,信息搜集:web3
安恒堡垒机如何启用Radius双因素/双因子(2FA)身份认证
Classification of regression tests
PG basics -- Logical Structure Management (locking mechanism -- table lock)
【跟着江科大学Stm32】STM32F103C8T6_PWM控制直流电机_代码
Stm32cubemx, 68 sets of components, following 10 open source protocols
Delete a whole page in word