zoukankan      html  css  js  c++  java
  • 获取数据库中所有表的行数及其他信息

    if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#Data'))
    drop table #Data
    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
    if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#DataNew'))
    drop table #DataNew
    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

  • 相关阅读:
    python+webdriver(二)
    python+webdriver(一)
    重逢
    在C,C++,java和python运行时解释器和编译器的区别
    hive调优
    github 操作指南
    jupyter 启动时的问题
    海量数据模型实施方法论
    python之Tkinker学习
    使用cmd命令行进行本地证书读取
  • 原文地址:https://www.cnblogs.com/ProgrammerHu/p/4268439.html
Copyright © 2011-2022 走看看