当前位置:网站首页> 大表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月 -21
5.观察系统负载,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删数据数据库异常的资料请关注软件开发网其它相关文章!
边栏推荐
- [Data Mining] Visual Pattern Mining: Hog Feature + cosinus Similarity / K - means Clustering
- [deep learning] image hyperspectral experiment: srcnn/fsrcnn
- Novel Slot Detection: A Benchmark for Discovering Unknown Slot Types in the Dialogue System
- Guangzhou Development Zone enables geographical indication products to help rural revitalization
- Ascend 910 realizes tensorflow1.15 to realize the Minist handwritten digit recognition of lenet network
- asp. Netnba information management system VS development SQLSERVER database web structure c programming computer web page source code project detailed design
- [understanding of opportunity -40]: direction, rules, choice, effort, fairness, cognition, ability, action, read the five layers of perception of 3GPP 6G white paper
- Concurrency Control & NoSQL and new database
- Zhiting doesn't use home assistant to connect Xiaomi smart home to homekit
- [server data recovery] data recovery case of raid failure of a Dell server
猜你喜欢
Niuke real problem programming - day14
Summer safety is very important! Emergency safety education enters kindergarten
MySQL bit type resolution
Niuke real problem programming - Day10
Bye, Dachang! I'm going to the factory today
[deep learning] semantic segmentation experiment: UNET network /msrc2 dataset
Ctfshow, information collection: web14
Ctfshow, information collection: web12
TypeScript 发布 4.8 beta 版本
安恒堡垒机如何启用Radius双因素/双因子(2FA)身份认证
随机推荐
Ctfshow, information collection: web12
word中删除一整页
MySQL bit type resolution
【目标检测】YOLOv5跑通VOC2007数据集
"Baidu Cup" CTF competition 2017 February, web:include
13 ux/ui/ue best creative inspiration websites in 2022
【深度学习】图像超分实验:SRCNN/FSRCNN
Ffmpeg --- image processing
Guangzhou Development Zone enables geographical indication products to help rural revitalization
Ctfshow, information collection: web2
众昂矿业:萤石继续引领新能源市场增长
[Data Mining] Visual Pattern Mining: Hog Feature + cosinus Similarity / K - means Clustering
TypeScript 发布 4.8 beta 版本
leetcode 241. Different Ways to Add Parentheses 为运算表达式设计优先级(中等)
如何在opensea批量发布NFT(Rinkeby测试网)
CTFshow,信息搜集:web12
Concurrency Control & NoSQL and new database
Read PG in data warehouse in one article_ stat
缓冲区溢出保护
What is cloud primordial? This time, I can finally understand!