当前位置:网站首页> 大表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删数据数据库异常的资料请关注软件开发网其它相关文章!
边栏推荐
- [server data recovery] a case of RAID data recovery of a brand StorageWorks server
- Spatiotemporal deformable convolution for compressed video quality enhancement (STDF)
- 【搞船日记】【Shapr3D的STL格式转Gcode】
- 【服务器数据恢复】某品牌StorageWorks服务器raid数据恢复案例
- “百度杯”CTF比赛 2017 二月场,Web:include
- Niuke real problem programming - day20
- Ctfshow, information collection: web9
- 摘抄的只言片语
- [make a boat diary] [shapr3d STL format to gcode]
- 缓冲区溢出保护
猜你喜欢

Used by Jetson AgX Orin canfd

Today's sleep quality record 78 points

JSON解析实例(Qt含源码)

15、文本编辑工具VIM使用

Yyds dry goods inventory # solve the real problem of famous enterprises: cross line

Ctfshow, information collection: web5

Ctfshow, information collection: web6

Novel Slot Detection: A Benchmark for Discovering Unknown Slot Types in the Dialogue System

Infinite innovation in cloud "vision" | the 2022 Alibaba cloud live summit was officially launched

Novel Slot Detection: A Benchmark for Discovering Unknown Slot Types in the Dialogue System
随机推荐
TypeScript 发布 4.8 beta 版本
Change win10 Screensaver
#yyds干货盘点# 解决名企真题:交叉线
Ascend 910 realizes tensorflow1.15 to realize the Minist handwritten digit recognition of lenet network
CTFshow,信息搜集:web14
Stm32f103c8t6 PWM drive steering gear (sg90)
CTFshow,信息搜集:web5
Ctfshow, information collection: Web3
2. 堆排序『较难理解的排序』
Delete a whole page in word
CTFshow,信息搜集:web7
Xiaomi's path of chip self-development
What is data leakage
Classification of regression tests
Ctfshow, information collection: web9
Andriod --- JetPack :LiveData setValue 和 postValue 的区别
知否|两大风控最重要指标与客群好坏的关系分析
Used by Jetson AgX Orin canfd
Today's sleep quality record 78 points
Novel Slot Detection: A Benchmark for Discovering Unknown Slot Types in the Dialogue System