时间:2021-05-22
获得SQL数据/日志空间使用,已使用的和未使用的空间的脚本
getSQLinfo.vbs
'scripttogetSQLDATA/LOGSpaceUsed,Spaceunused,
andSpaceFree
'Author:FelipeFerreira,DanielMagrini
'Date:05/07/07
'Version2,0
'@@TOCHANGE:::SERVERNAME\Instance,domain\user,passwordANDDATABSE!
'____________________________________________________________________________
ConstForReading=1,ForWriting=2,ForAppending=8
SetoFSO=CreateObject("Scripting.FilesyStemObject")
outputfile="CheckSqlDB_Size.txt"
Setofile=oFso.OpenTextFile(outputfile,8,True)
oFile.Writeline"######################################################"
oFile.Writeline"Thiscommandexecutedin"&Date&"at"&Time&VbCrLf
'____________________________________________________________________________
CheckSQLData
CheckSQLLOG
'##############GETSQLDATASPACEUSED,SPACETOTAL,SPACEFREE
'FunctioncheckSQL(strServer,strDB)inthefuturemakeitafunction....
SubCheckSQLDATA
ConstadOpenDynamic=1,adLockOptimistic=3
DimstrQuery
DimobjConnection,objRecordSet
DimstrQueryResult,strQueryResult2
DimUsedDataSpace,TotalDataSpace,FreeDataSpace
SetobjConnection=CreateObject("ADODB.Connection")
SetobjRecordSet=CreateObject("ADODB.Recordset")
objConnection.Open_
"Provider=SQLOLEDB.1;Server=192.168.8.10;UserID=sa;Password=lcx;Database=master;"
strQuery="DBCCshowfilestats"
objRecordSet.OpenstrQuery,objConnection,adOpenDynamic,adLockOptimistic
ifobjRecordSet.eofThen
'nothingreturned
wscript.echo"ERROR!!!"
Else
'NOTE:TogetthevalueinMB64/1024=0.0625
DoUntilobjRecordSet.eof
strQueryResult=objRecordSet.Fields("UsedExtents")
UsedDataSpace=strQueryResult*0.0625
strQueryResult2=objRecordSet.Fields("TotalExtents")
TotalDataSpace=strQueryResult2*0.0625
FreeDataSpace=TotalDataSpace-UsedDataSpace
'CleanData
UsedDataSpace=Left(UsedDataSpace,4)
FreeDataSpace=Left(FreeDataSpace,4)
TotalDataSpace=Left(TotalDataSpace,4)
'PrintResultonScreen
Wscript.echo"UsedSpace(MB)="&UsedDataSpace
Wscript.Echo"FreeSpace(MB)="&FreeDataSpace
Wscript.Echo"TotalSpace(MB)="&TotalDataSpace
'WriteonFile
ofile.WriteLine"UsedDATASpace(MB)="&UsedDataSpace
ofile.WriteLine"FreeDATASpace(MB)="&FreeDataSpace
ofile.WriteLine"TotalDATASpace(MB)="&TotalDataSpace
objRecordSet.MoveNext
loop
endif
objRecordSet.Close
objConnection.Close
setobjConnection=nothing
setobjRecordSet=nothing
endsub
SubCheckSQLLOG
ConstadOpenDynamic=1,adLockOptimistic=3
DimstrQuery
DimobjConnection,objRecordSet
DimstrQueryResult,strQueryResult2
DimUsedLogSpace,TotalLogSpace,FreeLogSpace
SetobjConnection=CreateObject("ADODB.Connection")
SetobjRecordSet=CreateObject("ADODB.Recordset")
objConnection.Open_
"Provider=SQLOLEDB.1;Server=192.168.8.10;UserID=sa;Password=lcx;Database=master;"
strQuery="DBCCSQLPERF(LOGSPACE)"
objRecordSet.OpenstrQuery,objConnection,adOpenDynamic,adLockOptimistic
ifobjRecordSet.eofThen
'nothingreturned
wscript.echo"ERROR!!!"
Else
DoUntilobjRecordSet.eof
IfobjRecordSet.Fields("DatabaseName")="master"Then
strQueryResult=objRecordSet.Fields("LogSize(MB)")
strQueryResult2=objRecordSet.Fields("LogSpaceUSed(%)")
UsedLogSpace=(strQueryResult*strQueryResult2)/100
TotalLogSpace=strQueryResult
FreeLogSpace=TotalLogSpace-UsedLogSpace
'CleanData
UsedLogSpace=Left(UsedLogSpace,4)
FreeLogSpace=Left(FreeLogSpace,4)
TotalLogSpace=Left(TotalLogSpace,4)
'PrintResultonScreen
Wscript.echo"UsedSpace(MB)="&UsedLogSpace
Wscript.Echo"FreeSpace(MB)="&FreeLogSpace
Wscript.Echo"TotalSpace(MB)="&TotalLogSpace
'WriteonFile
oFile.WriteLine"UsedLOGSpace(MB)="&UsedLogSpace
oFile.WriteLine"FreeLOGSpace(MB)="&FreeLogSpace
oFile.WriteLine"TotalLOGSpace(MB)="&TotalLogSpace
oFile.close
ExitDo
EndIf
objRecordSet.MoveNext
loop
endif
objRecordSet.Close
objConnection.Close
setobjConnection=nothing
setobjRecordSet=nothing
endsub
WSCript.Quit
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
1.查询表空间使用情况:sqlplussystem/manager@topprod复制代码代码如下:SQL>@q_tbsFREE2.查询temp使用方法:sql
查看磁盘空间使用情况:[root@srv-jigocity-web1iplocate]#df-mFilesystem1M-blocksUsedAvailable
华为Mate10和Mate10pro手机搭载了全新的EMUI8.0系统,长时间使用手机,不清楚内存和存储的详细占用情况。您可以查看手机内存和存储空间的使用情况,
信许多Mac用户都和PC6小编一样挺关注Mac电脑磁盘占用情况的。如果你查看电脑的“关于本机”部分,即可得到磁盘空间使用情况的简要概述,
随着手机使用时间的增加,手机可用的储存空间也会慢慢变小。如果要了解手机的储存空间使用情况应该怎么查看呢?华为手机储存空间查看清理教程打开手机自带的设置功能。进入