//查询数据库中所有的表名及行数 SELECT a.name, b.rows FROM sysobjects AS a INNER JOIN sysindexes AS b ON a.id = b.id WHERE (a.type = 'u') AND (b.indid IN (0, 1)) ORDER BY b.rows DESC //查询所有的标明及空间占用量行数 SELECT OBJECT_NAME(id) AS tablename, 8 * reserved / 1024 AS reserved, RTRIM(8 * dpages/1024) + 'MB' AS used, 8 * (reserved - dpages) / 1024/1024 AS unused, 8 * dpages / 1024 - rows / 1024 * minlen / 1024/1024 AS free FROM sys.sysindexes WHERE (indid = 1) ORDER BY reserved DESC // create index CREATE INDEX idx_product_workorder_process_defect_detail_createdtON dbo.PRODUCT_WORKORDER_PROCESS_DEFECT_DETAIL(CreateDT) INCLUDE(DefectFkId)