sqlserver查詢數據的所有表名和行數


 1 //查詢所有表明 select name from sysobjects where xtype='u'
 2 
 3 select * from sys.tables
 4  //查詢數據庫中所有的表名及行數
 5 
 6 SELECT a.name, b.rows
 7 
 8 FROM sysobjects AS a INNER JOIN sysindexes AS b ON a.id = b.id
 9 
10 WHERE (a.type = 'u') AND (b.indid IN (0, 1))
11 
12 ORDER BY a.name,b.rows DESC
13 
14  //查詢所有的標明及空間占用量\行數
15 
16 select
17 
18 object_name(id) tablename,
19 
20 8*reserved/1024 reserved,
21 
22 rtrim(8*dpages)+'kb' used,
23 
24 8*(reserved-dpages)/1024 unused,
25 
26 8*dpages/1024-rows/1024*minlen/1024 free,
27 
28 rows
29 
30 --,*
31 
32 from sysindexes
33 
34 where indid=1
35 
36 order by tablename,reserved desc
View Code

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM