Advertisement
CuriousStudent

Untitled

Mar 7th, 2023
1,340
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.90 KB | None | 0 0
  1. set showplan_text off
  2. set statistics io on
  3. go
  4.  
  5. select top 10 *
  6. from customer
  7. where birthday = '1957-01-01'
  8.  
  9. -- Parametry heap tabulky
  10. SELECT
  11.   t.NAME AS TableName,
  12.   p.rows AS RowCounts,
  13.   SUM(a.total_pages) AS TotalBlocks,
  14.   SUM(a.used_pages) AS UsedBlocks
  15. FROM sys.tables t
  16. INNER JOIN      
  17.   sys.indexes i ON t.OBJECT_ID = i.object_id
  18. INNER JOIN
  19.   sys.partitions p ON i.object_id = p.OBJECT_ID AND
  20.   i.index_id = p.index_id
  21. INNER JOIN
  22.   sys.allocation_units a ON p.partition_id = a.container_id
  23. WHERE t.NAME = 'CUSTOMER'
  24. GROUP BY t.Name, p.Rows
  25. ORDER BY t.Name
  26.  
  27.  
  28. -- Indexy tabulky
  29. SELECT
  30.   TableName = t.Name,
  31.   i.*
  32. FROM
  33.   sys.indexes i
  34. INNER JOIN
  35.   sys.tables t ON t.object_id = i.object_id
  36. WHERE
  37.   T.Name = 'Customer' and i.name is not null;
  38.  
  39.  
  40. -- Vyska B-stromu na tabulce
  41. SELECT INDEXPROPERTY(OBJECT_ID('Customer'),
  42.   'PK__Customer__D0587687D76E98AD', 'IndexDepth') - 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement