kb mb of db.sql

本文介绍了一个SQL脚本,用于批量查询并更新数据库中所有非系统表的表空间信息,包括表名、行数、预留空间、数据大小、索引大小和未使用空间,最终将数据存储在一个结果表中。

if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tablespaceinfo]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
create table tablespaceinfo --创建结果存储表
(nameinfo varchar(50) ,
rowsinfo int , reserved varchar(20) ,
datainfo varchar(20) ,
index_size varchar(20) ,
unused varchar(20) )

delete from tablespaceinfo --清空数据表

declare @tablename varchar(255) --表名称

declare @cmdsql varchar(500)

DECLARE Info_cursor CURSOR FOR
select o.name
from dbo.sysobjects o where OBJECTPROPERTY(o.id, N'IsTable') = 1
and o.name not like N'#%%' order by o.name

OPEN Info_cursor

FETCH NEXT FROM Info_cursor
INTO @tablename

WHILE @@FETCH_STATUS = 0
BEGIN

if exists (select * from dbo.sysobjects where id = object_id(@tablename) and OBJECTPROPERTY(id, N'IsUserTable') = 1)
execute sp_executesql
N'insert into tablespaceinfo exec sp_spaceused @tbname',
N'@tbname varchar(255)',
@tbname = @tablename

FETCH NEXT FROM Info_cursor
INTO @tablename
END

CLOSE Info_cursor
DEALLOCATE Info_cursor
GO


--itlearner注:显示数据库信息
sp_spaceused @updateusage = 'TRUE'

--itlearner注:显示表信息
select *
from tablespaceinfo
order by cast(left(ltrim(rtrim(reserved)) , len(ltrim(rtrim(reserved)))-2) as int) desc

Memory limit exceeded: Query single node mem exceeded 20.00 GB\nError occurred on backend 10.49.93.200:27000 by fragment e34e6940043d43b0:8636357a0000008d\nMemory left in process limit: 55.65 GB\nQuery(e34e6940043d43b0:8636357a00000000): Reservation=19.96 GB ReservationLimit=68.00 GB OtherMemory=91.59 MB Total=20.05 GB Peak=20.05 GB\n Unclaimed reservations: Reservation=35.94 MB OtherMemory=0 Total=35.94 MB Peak=93.94 MB\n Fragment e34e6940043d43b0:8636357a0000008d: Reservation=18.27 GB OtherMemory=35.68 MB Total=18.30 GB Peak=18.30 GB\n AGGREGATION_NODE (id=2): Reservation=17.16 GB OtherMemory=51.12 KB Total=17.16 GB Peak=17.16 GB\n GroupingAggregator 0: Reservation=17.16 GB OtherMemory=43.12 KB Total=17.16 GB Peak=17.16 GB\n Exprs: Total=43.12 KB Peak=43.12 KB\n HDFS_SCAN_NODE (id=1): Reservation=1.11 GB OtherMemory=35.09 MB Total=1.14 GB Peak=1.18 GB\n Exprs: Total=288.00 KB Peak=288.00 KB\n Queued Batches: Total=13.58 MB Peak=56.83 MB\n KrpcDataStreamSender (dst_id=4): Total=539.30 KB Peak=539.30 KB\n RowBatchSerialization: Total=0 Peak=0\n Fragment e34e6940043d43b0:8636357a000000db: Reservation=0 OtherMemory=590.42 KB Total=590.42 KB Peak=590.42 KB\n AGGREGATION_NODE (id=5): Reservation=0 OtherMemory=43.12 KB Total=43.12 KB Peak=43.12 KB\n GroupingAggregator 0: Total=43.12 KB Peak=43.12 KB\n Exprs: Total=43.12 KB Peak=43.12 KB\n EXCHANGE_NODE (id=4): Reservation=0 OtherMemory=0 Total=0 Peak=0\n KrpcDeferredRpcs: Total=0 Peak=0\n KrpcDataStreamSender (dst_id=7): Total=539.30 KB Peak=539.30 KB\n RowBatchSerialization: Total=0 Peak=0\n Fragment e34e6940043d43b0:8636357a0000010f: Reservation=0 OtherMemory=8.71 MB Total=8.71 MB Peak=8.71 MB\n HASH_JOIN_NODE (id=3): Total=50.25 KB Peak=50.25 KB\n Exprs: Total=17.12 KB Peak=17.12 KB\n Hash Join Builder (join_node_id=3): Total=17.12 KB Peak=17.12 KB\n Hash Join Builder (join_node_id=3) Exprs: Total=17.12 KB Peak=17.12 KB\n EXCHANGE_NODE (id=6): Reservation=8.65 MB OtherMemory=0 Total=8.65 MB Peak=8.65 MB\n KrpcDeferredRpcs: Total=0 Peak=332.08 KB\n EXCHANGE_NODE (id=7): Reservation=0 OtherMemory=0 Total=0 Peak=0\n KrpcDeferredRpcs: Total=0 Peak=0\n HdfsTableSink: Total=0 Peak=0\n Fragment e34e6940043d43b0:8636357a00000025: Reservation=1.66 GB OtherMemory=46.60 MB Total=1.71 GB Peak=1.71 GB\n HDFS_SCAN_NODE (id=0): Reservation=1.66 GB OtherMemory=26.81 MB Total=1.69 GB Peak=1.69 GB\n Queued Batches: Total=26.81 MB Peak=26.81 MB\n KrpcDataStreamSender (dst_id=6): Total=19.65 MB Peak=19.70 MB\n RowBatchSerialization: Total=15.95 MB Peak=16.00 MB\n CodeGen: Total=10.85 KB Peak=1.57 MB\n CodeGen: Total=4.31 KB Peak=1.09 MB\n CodeGen: Total=3.01 KB Peak=871.50 KB\n CodeGen: Total=6.01 KB Peak=1.30 MB\这个报错什么意思
最新发布
09-19
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值