SQL SERVER 2008 新功能:physical row locator function
今天同事問我個問題
Page ID = 0001:0015fdb3
0015fdb3 這個值 可以和那個系統表的那個欄位的值對應起來。
我還一時不知道
GOOGLE了下。
找到一篇不錯的文章:
內容如下:
One of the drawbacks of not being in the SQL team at Microsoft any longer is that I don't know about all the undocumented features in the next release - I have to hunt around for them like everyone else :-(
So I was poking about in SSMS in 2008 CTP-6 and noticed a function called sys.fn_PhysLocCracker that I'd never heard of. Doing an sp_helptext on it gets the following output:
-- Name: sys.fn_PhysLocCracker
--
-- Description:
-- Cracks the output of %%physloc%% virtual column
--
-- Notes:
-------------------------------------------------------------------------------
create function sys.fn_PhysLocCracker (@physical_locator binary (8))
returns @dumploc_table table
(
[file_id] int not null,
[page_id] int not null,
[slot_id] int not null
)
as
begindeclare @page_id binary (4)
declare @file_id binary (2)
declare @slot_id binary (2)-- Page ID is the first four bytes, then 2 bytes of page ID, then 2 bytes of slot
--
select @page_id = convert (binary (4), reverse (substring (@physical_locator, 1, 4)))
select @file_id = convert (binary (2), reverse (substring (@physical_locator, 5, 2)))
select @slot_id = convert (binary (2), reverse (substring (@physical_locator, 7, 2)))
insert into @dumploc_table values (@file_id, @page_id, @slot_id)
return
end
Cool - but something else I've never heard of %%physloc%% - what's that? After playing around for a while, I figured out how to make it work. Just to be confusing, there's another identical version of the function called sys.fn_PhysLocFormatter - and that's the only one I could get to work. Here's an example:
CREATE TABLE TEST (c1 INT IDENTITY, c2 CHAR (4000) DEFAULT 'a');
GO
INSERT INTO TEST DEFAULT VALUES;
INSERT INTO TEST DEFAULT VALUES;
INSERT INTO TEST DEFAULT VALUES;
GOSELECT sys.fn_PhysLocFormatter (%%physloc%%) AS [Physical RID], * FROM TEST;
GOPhysical RID c1
----------------- -----------
(1:411:0) 1
(1:411:1) 2
(1:413:0) 3
It's a physical-record locator function! Undocumented and unsupported (obviously), but hey, some of the best features are :-) It gives the database file, page within the file, and slot number on the page in the format (file:page:slot). I can think of a *bunch* of uses for this which I'll be exploring over the next few months
.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/8183550/viewspace-693658/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- SQL Server 2008中Analysis Services的新特性——深入SQL Server 2008SQLServer
- SQL SERVER 2008安全配置SQLServer
- SQL Server 2008連線字串寫法大全SQLServer字串
- SQL Server2008程式堵塞處理方法SQLServer
- Sql Server2008R2下載地址SQLServer
- SQL Server 2008中的行壓縮(上)JUSQLServer
- Analysis Services基礎知識——深入SQL Server 2008SQLServer
- win10怎麼安裝sql server2008 r2_win10如何安裝sql server2008 r2Win10SQLServer
- SQL Server中row_number函式的常見用法SQLServer函式
- SQL Server 2008事件處理系統簡介LSSQLServer事件
- SQL Server 2008的故障轉移叢集概述UBSQLServer
- 理解SQL Server 2008索引的儲存結構YDSQLServer索引
- SQL Server 2008 R2雙機熱備方案SQLServer
- SQL Server 2012新功能巡禮:高可用AlwaysOnZOSQLServer
- SQL Server 2008檔案流功能應用設想YCSQLServer
- SQL Server2008 R2 資料庫映象配置方案SQLServer資料庫
- Q&A:SQL Server 2008的升級與部署知識SOSQLServer
- 1.4 SQL Server2008安裝與配置(2020-12-1)SQLServer
- SQL Server 2012新功能巡禮:列儲存索引YXSQLServer索引
- SQL Server Denali開發工具SSDT新功能解讀ZLSQLServer
- 在SQL Server 2008中的SP上使用表型別值引數MHSQLServer型別
- SQL Server 2008 R2並行資料倉儲簡介SZSQLServer並行
- 雲伺服器SQL Server 2008 允許遠端連線的配置伺服器SQLServer
- 關於SQL server2008除錯儲存過程的完整步驟SQLServer除錯儲存過程
- 注意:微軟將在2019年7月停止對SQL Server 2008的支援!微軟SQLServer
- SQL Server 2008資料複製新特性及其帶來的價值(下)XDSQLServer
- SQL Server 2000/2005/2008刪除或壓縮資料庫日誌的方法SQLServer資料庫
- Service Locator 模式模式
- sql中row_number over語句SQL
- sql serverSQLServer
- Windows 10 下安裝Sql Server 2008 R2 連線到伺服器失敗WindowsSQLServer伺服器
- Windows Server 2008 R2 下載地址WindowsServer
- 區分SQL Server 2008 R2資料中心和並行資料倉儲版本WBSQLServer並行
- Moebius for SQL ServerSQLServer
- sql server 使用SQLServer
- SQL Server教程SQLServer
- Windows Server 2008 RC候選版要釋出了WindowsServer
- windows server2008安裝mysql資料庫WindowsServerMySql資料庫
- win server 2008 重啟之“0x80041003”Server