当前位置:网站首页>清楚临时表、查看临时表占用内存
清楚临时表、查看临时表占用内存
2022-07-16 04:37:00 【 浊尘】
--登记表记录
select * from T_BAS_TEMPORARYTABLENAME where FPROCESSTYPE=1 or FCREATEDATE<GETDATE()-1
delete from T_BAS_TEMPORARYTABLENAME where FPROCESSTYPE=1 or FCREATEDATE<GETDATE()-1
--删除临时表
if object_id('temptb','table')>0 drop table temptb;
declare @sql varchar(max)
declare @icount int
declare @I int
set @sql='drop table 'set @i=1select name,IDENTITY(int,1,1) id into temptb from sys.tables t
where name like 'tmp%' and not exists(select 1 from T_BAS_TEMPORARYTABLENAME where FTABLENAME=t.name) and create_date<=DATEADD(n,-5, GETDATE())
select @icount=@@ROWCOUNT
while @i<@icount
begin select @sql=@sql+name+',' from temptb
where id between @i and @i+49
if @@ROWCOUNT>0
set @sql=substring(@sql,1,len(@sql)-1)+';'
set @i=@i+50 exec(@sql) set @sql='drop table 'end
if object_id('temptb','table')>0 drop table temptb;
--查看占用内存
select cast(sum(a.total_pages)*8/1024 as varchar)+' MB' total
from sys.partitions p
join sys.allocation_units a on p.partition_id = a.container_id
join sys.tables it on p.object_id = it.object_id
where it.name like 'TMP%'
边栏推荐
- Matlab科研绘图颜色补充(特别篇6)—336种法国传统颜色
- The open and closed interval of the mean value theorem of higher numbers | integrals, the first mean value theorem of integrals and its generalization
- SQL必知必会挑战题答案
- Abbyy finereader 15 standard OCR character recognition and PDF editing software tool
- filebeat收集kubernetes集群日志
- AB控制器 L36ERM_2个处理器之间的通讯
- Color supplement of MATLAB scientific research drawing (special part 6) - 336 traditional French colors
- Automatic completion (spring daily question 58)
- Interview problem: how to close an order without using a scheduled task?
- PMP practice once a day | don't get lost in the exam -7.15
猜你喜欢

Laozi cloud 3D products and services are introduced. A picture shows you how to choose!

marginalization

Cultural tourism night tour project helps the development of night economy

Color supplement of MATLAB scientific research drawing (special part 6) - 336 traditional French colors

盒子模型、文檔流、定比特、布局和響應式設計

Advanced principle of MySQL: MySQL execution process and order

Matlab机械臂建模运动学仿真+轨迹规划

AB PLC学习笔记

2.18 haas506 2.0 development tutorial - communication between Alibaba cloud M2M devices - rule engine /topic message routing (only versions above 2.2 are supported)

基于SSH的网上商城
随机推荐
Securities account Guotai Junan? Is it safe?
【目标跟踪】基于背景消减的图像帧间差分法目标检测及matlab仿真
Reduction of type
2018 Jiangsu Provincial Information and future programming expert competition test question -- (New) chicken and rabbit in the same cage
AB controller l36erm_ Communication between two processors
盒子模型、文檔流、定比特、布局和響應式設計
MySQL - ER model
Idea merges dev branch code into master and so on
preg_replace 代码执行漏洞之[BJDCTF2020]ZJCTF,不过如此
老子云3D产品及服务全介绍,一张图告诉你如何选!
Tencent employees post to find objects, indicating that they prefer programmers! Comments are hot Dark horse headlines
Notes on logical problem solving in English reading
2018年江苏省信息与未来程序设计小能手比赛试题--(新)鸡兔同笼标程
T100 user defined application instructions (azzi650)
Differences between collections and collections
Summary of application packaging and multi terminal compatibility
文旅夜游:城市经济复苏增长新机遇
Three lines (spring daily question 59)
Iptables mask access to a port of IP
How to optimize the performance of canvas?