查找表包含的页和页所在的表

1. 查找表包含的页信息:
   查找表包含的页信息可以使用 dbcc ind
   语法:

 
  
DBCC IND
(
[ 'database name'|database id ] , -- the database to use
table name, -- the table name to list results
index id, -- an index_id from sys.indexes; -1 shows all indexes and IAMs, -2 just show IAMs
)


   例如:

 
  
dbcc ind( 9 ,tablename, - 1 )


       image

2. 查找页所在的表(一个页只能属于一个对象)
   查找页所在的表,可以用 dbcc page
   语法:

 
  
DBCC PAGE
(
[ 'database name'|database id ] , -- can be the actual name or id of the database
file number , -- the file number where the page is found
page number , -- the page number within the file
print option = [ 0|1|2|3 ] -- display option; each option provides differing levels of information
)

   例如:(注意需要开启3604标记)

 
  
DBCC TRACEON ( 3604 )
DBCC PAGE( ' dbname ' , 1 , 5253 , 1 ) -- with tableresults
DBCC TRACEOFF ( 3604 )

   输出如下:
    image
  
   可以得到 Metadata: ObjectId = 478676803 和 Metadata: IndexId = 1
   根据这两个信息可以得到具体信息

 
  
select s.name,o.name,i.id,i.indid,i.name from
sys.sysobjects o
inner join sys.schemas s on o.uid = s.schema_id inner join sys.sysindexes i on o.id = i.id
where o.id = 478676803 and i.indid = 1


     image
  
   查找具体索引信息

 
  
exec sp_helpindex ' dbname.dbo.tablename’


   image

转载于:https://www.cnblogs.com/fygh/archive/2011/04/20/2022322.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值