create table #data(name varchar(100),row varchar(100),reserved varchar(100),data varchar(100),index_size varchar(100),unused varchar(100))
declare @name varchar(100)
declare cur cursor for
select name from sysobjects where xtype='u' order by name
open cur
fetch next from cur into @name
while @@fetch_status=0
begin
insert into #data
exec sp_spaceused @name
print @name
fetch next from cur into @name
end
close cur
deallocate cur
create table #datanew(name varchar(100),row int,reserved int,data int,index_size int,unused int)
insert into #datanew
select name,convert(int,row) as row,convert(int,replace(reserved,'kb','')) as reserved,convert(int,replace(data,'kb','')) as data,
convert(int,replace(index_size,'kb','')) as index_size,convert(int,replace(unused,'kb','')) as unused from #data
select * from #datanew order by row desc
sql表記錄鄰近計算
引入 視窗函式 row number lead 表名aaa 按照uid,cid對ts鄰近記錄進行減法,獲取記錄的停留時間 sql如下 select uid,cid,chapter,ts,action type,row number over partition by uid,cid order by...
資料表記錄的增刪改查
模型表資料的增刪改查 對資料庫內資料表中的表記錄進行操作 查 filter data models.user.objects.filter username username filter返回的結果是乙個 列表 裡面才是真正資料物件 filer括號內可以放多個關鍵字引數 這多個關鍵字引數在查詢的時候...
查詢資料庫表記錄數
select table name,table rows from information schema.tables order by table rows desc limit 20 個別表的資料太大了,這才執行半年多吧,這樣下去不知道資料庫會不會有問題 大致看了下資料,發現模擬量上傳的資料一分...