查看temp db
发表于:2024-12-12 作者:千家信息网编辑
千家信息网最后更新 2024年12月12日,use tempdb-- 每隔1秒钟运行一次,直到用户手工终止脚本运行while 1=1beginselect getdate()-- 从文件级看tempdb使用情况dbcc showfilestat
千家信息网最后更新 2024年12月12日查看temp dbuse tempdb
-- 每隔1秒钟运行一次,直到用户手工终止脚本运行
while 1=1
begin
select getdate()
-- 从文件级看tempdb使用情况
dbcc showfilestats
-- Query 1
-- 返回所有做过空间申请的session信息
Select 'Tempdb' as DB, getdate() as Time,
SUM (user_object_reserved_page_count)*8 as user_objects_kb,
SUM (internal_object_reserved_page_count)*8 as internal_objects_kb,
SUM (version_store_reserved_page_count)*8 as version_store_kb,
SUM (unallocated_extent_page_count)*8 as freespace_kb
From sys.dm_db_file_space_usage
Where database_id = 2
-- Query 2
-- 这个管理视图能够反映当时tempdb空间的总体分配
SELECT t1.session_id,
t1.internal_objects_alloc_page_count, t1.user_objects_alloc_page_count,
t1.internal_objects_dealloc_page_count , t1.user_objects_dealloc_page_count,
t3.*
from sys.dm_db_session_space_usage t1 ,
-- 反映每个session累计空间申请
sys.dm_exec_sessions as t3
-- 每个session的信息
where
t1.session_id = t3.session_id
and (t1.internal_objects_alloc_page_count>0
or t1.user_objects_alloc_page_count >0
or t1.internal_objects_dealloc_page_count>0
or t1.user_objects_dealloc_page_count>0)
-- Query 3
-- 返回正在运行并且做过空间申请的session正在运行的语句
SELECT t1.session_id,
st.text
from sys.dm_db_session_space_usage as t1,
sys.dm_exec_requests as t4
CROSS APPLY sys.dm_exec_sql_text(t4.sql_handle) AS st
where t1.session_id = t4.session_id
and t1.session_id >50
and (t1.internal_objects_alloc_page_count>0
or t1.user_objects_alloc_page_count >0
or t1.internal_objects_dealloc_page_count>0
or t1.user_objects_dealloc_page_count>0)
waitfor delay '0:0:1'
end
-- 每隔1秒钟运行一次,直到用户手工终止脚本运行
while 1=1
begin
select getdate()
-- 从文件级看tempdb使用情况
dbcc showfilestats
-- Query 1
-- 返回所有做过空间申请的session信息
Select 'Tempdb' as DB, getdate() as Time,
SUM (user_object_reserved_page_count)*8 as user_objects_kb,
SUM (internal_object_reserved_page_count)*8 as internal_objects_kb,
SUM (version_store_reserved_page_count)*8 as version_store_kb,
SUM (unallocated_extent_page_count)*8 as freespace_kb
From sys.dm_db_file_space_usage
Where database_id = 2
-- Query 2
-- 这个管理视图能够反映当时tempdb空间的总体分配
SELECT t1.session_id,
t1.internal_objects_alloc_page_count, t1.user_objects_alloc_page_count,
t1.internal_objects_dealloc_page_count , t1.user_objects_dealloc_page_count,
t3.*
from sys.dm_db_session_space_usage t1 ,
-- 反映每个session累计空间申请
sys.dm_exec_sessions as t3
-- 每个session的信息
where
t1.session_id = t3.session_id
and (t1.internal_objects_alloc_page_count>0
or t1.user_objects_alloc_page_count >0
or t1.internal_objects_dealloc_page_count>0
or t1.user_objects_dealloc_page_count>0)
-- Query 3
-- 返回正在运行并且做过空间申请的session正在运行的语句
SELECT t1.session_id,
st.text
from sys.dm_db_session_space_usage as t1,
sys.dm_exec_requests as t4
CROSS APPLY sys.dm_exec_sql_text(t4.sql_handle) AS st
where t1.session_id = t4.session_id
and t1.session_id >50
and (t1.internal_objects_alloc_page_count>0
or t1.user_objects_alloc_page_count >0
or t1.internal_objects_dealloc_page_count>0
or t1.user_objects_dealloc_page_count>0)
waitfor delay '0:0:1'
end
点击(此处)折叠或打开
- select replace(a.hostname,' ','') as hostname ,''''+replace(program_name,' ','')+'''' as program_name
- , loginame, j.*
- from (
- SELECT t1.session_id, t1.internal_objects_alloc_page_count*8.0 internal_objects_alloc_KB,
- t1.user_objects_alloc_page_count*8.0 user_objects_alloc_KB,
- t1.internal_objects_dealloc_page_count*8.0 internal_objects_dealloc_KB,
- t1.user_objects_dealloc_page_count*8.0 user_objects_dealloc_KB,
- st.text
- from sys.dm_db_session_space_usage as t1,
- sys.dm_exec_requests as t4
- CROSS APPLY sys.dm_exec_sql_text(t4.sql_handle) AS st
- where t1.session_id = t4.session_id
- and t1.session_id >50
- and (t1.internal_objects_alloc_page_count>0
- or t1.user_objects_alloc_page_count >0
- or t1.internal_objects_dealloc_page_count>0
- or t1.user_objects_dealloc_page_count>0) ) as j
- left join
- sys.sysprocesses as a with(nolock) on a.spid=j.session_id
- where isnull(a.loginame,'') <>''
点击(此处)折叠或打开
- select j.session_id,replace(s.hostname,' ','') as hostname ,''''+replace(s.program_name,' ','')+'''' as program_name
- , s.loginame, db_name(s.dbid) AS DBname,j.text from
- ( SELECT t1.session_id,st.text
- from sys.dm_db_session_space_usage as t1,
- sys.dm_exec_requests as t4
- CROSS APPLY sys.dm_exec_sql_text(t4.sql_handle) AS st
- where t1.session_id = t4.session_id
- and t1.session_id >50
- and (t1.internal_objects_alloc_page_count>0
- or t1.user_objects_alloc_page_count >0
- or t1.internal_objects_dealloc_page_count>0
- or t1.user_objects_dealloc_page_count>0)) as j
- left join
- sys.sysprocesses as s with(nolock) on s.spid=j.session_id
- where isnull(s.loginame,'') <>''
点击(此处)折叠或打开
- select sum(convert(float,size) * (8192/1024)/1024/1024) TMPFILE_GB, sum(convert(float,maxsize) * (8192/1024)/1024/1024) MAX_TMPFILE_GB,(sum(size)*1.0/sum(maxsize))*100 USED_PER from tempdb.dbo.sysfiles
- where name like 'tempdev%'
- select * from tempdb.dbo.sysfiles
点击(此处)折叠或打开
- use tempdb
- -- 每隔1秒钟运行一次,直到用户手工终止脚本运行
- while 1=1
- begin
- select getdate()
- -- 从文件级看tempdb使用情况
- dbcc showfilestats
- -- Query 1
- -- 返回所有做过空间申请的session信息
- Select 'Tempdb' as DB, getdate() as Time,
- SUM (user_object_reserved_page_count)*8 as user_objects_kb,
- SUM (internal_object_reserved_page_count)*8 as internal_objects_kb,
- SUM (version_store_reserved_page_count)*8 as version_store_kb,
- SUM (unallocated_extent_page_count)*8 as freespace_kb
- From sys.dm_db_file_space_usage
- Where database_id = 2
- -- Query 2
- -- 这个管理视图能够反映当时tempdb空间的总体分配
- SELECT t1.session_id,
- t1.internal_objects_alloc_page_count, t1.user_objects_alloc_page_count,
- t1.internal_objects_dealloc_page_count , t1.user_objects_dealloc_page_count,
- t3.*
- from sys.dm_db_session_space_usage t1 ,
- -- 反映每个session累计空间申请
- sys.dm_exec_sessions as t3
- -- 每个session的信息
- where
- t1.session_id = t3.session_id
- and (t1.internal_objects_alloc_page_count>0
- or t1.user_objects_alloc_page_count >0
- or t1.internal_objects_dealloc_page_count>0
- or t1.user_objects_dealloc_page_count>0)
- -- Query 3
- -- 返回正在运行并且做过空间申请的session正在运行的语句
- SELECT t1.session_id,
- st.text
- from sys.dm_db_session_space_usage as t1,
- sys.dm_exec_requests as t4
- CROSS APPLY sys.dm_exec_sql_text(t4.sql_handle) AS st
- where t1.session_id = t4.session_id
- and t1.session_id >50
- and (t1.internal_objects_alloc_page_count>0
- or t1.user_objects_alloc_page_count >0
- or t1.internal_objects_dealloc_page_count>0
- or t1.user_objects_dealloc_page_count>0)
- waitfor delay '0:0:1'
- end
空间
运行
空间申请
信息
正在
总体
情况
手工
文件
用户
脚本
视图
语句
分配
管理
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
诺亚之心服务器未连接
莱茵网络安全
俄罗斯网络技术水平
坪山区品牌网络技术优化
access数据库模块函数题
国产网络视频服务器厂家
服务器建立新硬盘
微软混合云数据库
山西太原dns服务器云服务器
绝地求生2怎样切换服务器
科技app软件开发公司电话
数据库统计每个人的总分
华夏恒生互联网科技业指数
数据库双向同步
软件开发很容易秃顶
幻塔服务器维护后效果更好了
播出视频服务器
光遇账号怎么查看服务器
网易服务器hypixel
网络安全黑客克星
企业管理软件用什么服务器
信息安全多级数据库问题
怎么在查看网络安全性
宁南县软云软件开发有限公司
ai智能软件开发怎么样
软件开发很容易秃顶
全国网络安全员竞赛答题
软件开发测试性格不合
网络安全运维没文化
服务器fpga作用