• Mysql和Sql查询表信息


    Mysql

    SELECT TABLE_NAME,TABLE_ROWS,DATA_LENGTH/1024/1024 "DATA_LENGTH",CREATE_TIME,TABLE_COLLATION 
    FROM
    INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '数据库名称' ORDER BY TABLE_ROWS DESC
    

      

    Sql

    IF OBJECT_ID('tempdb..#TablesSizes') IS NOT NULL
    
        DROP TABLE #TablesSizes
    
    CREATE TABLE #TablesSizes
    
        (
    
          TableName sysname ,
    
          Rows BIGINT ,
    
          reserved VARCHAR(100) ,
    
          data VARCHAR(100) ,
    
          index_size VARCHAR(100) ,
    
          unused VARCHAR(100)
    
        )
    
    DECLARE @sql VARCHAR(MAX)
    
    SELECT  @sql = COALESCE(@sql, '') + '
    
    INSERT INTO #TablesSizes execute sp_spaceused ''' + QUOTENAME(TABLE_SCHEMA,
    
                                                                  '[]') + '.'
    
            + QUOTENAME(Table_Name, '[]') + ''''
    
    FROM    INFORMATION_SCHEMA.TABLES
    
    WHERE   TABLE_TYPE = 'BASE TABLE'
    
    PRINT ( @SQL )
    
    EXECUTE (@SQL)
    
    SELECT  *
    
    FROM    #TablesSizes
    
    ORDER BY Rows DESC
    

      

      

  • 相关阅读:
    poj1580
    poj1607
    poj1313
    poj1314
    c语言之extern和static
    C笔记(一)
    搭建Linux高可用性集群(第一天)
    利用回调函数实现泛型算法
    关于SQL server中的 identity
    SQL(一)
  • 原文地址:https://www.cnblogs.com/lhlong/p/15247197.html
Copyright © 2020-2023  润新知