【Data Platform】/SQL Server

[2k5] max 타입 내부 forwarding 보기 및 dbcc extentinfo 확인

디비랑 2008. 9. 7. 12:06
  1. /**********************************************************************************************
    -- Title : [2k5] max 타입 내부 forwarding 보기 및 dbcc extentinfo 확인
    -- Reference : mcpworld.com
    -- Key word : max dbcc extentinfo traceon page forward pointer
    **********************************************************************************************/
    use master;
    go
     
    drop database newdatatype;
    go
     
    create database newdatatype;
    go
     
    use newdatatype;
    go
     
    create table bigtable
    ( id int, col1 varchar(25)
    , col2 varchar(max)
    , col3 varchar(max)
    );
    go
     
    insert into bigtable values (1, 'row1', 'aaaaaaaaaa', 'aaaaaaaaaa');
    insert into bigtable values (2, 'row2', 'bbbbbbbbbb', 'bbbbbbbbbb');
    go
     
    select * from sysindexes
    where id=object_id('bigtable');
    go
     
    -- first = ?
    dbcc extentinfo ('newdatatype', 'bigtable'); /*dbcc extentinfo 새로 나왔나?*/
    go
     
    -- file_id = 1
    -- page_id = 40
    dbcc traceon (3604);
    go
     
    dbcc page ('newdatatype', 1, 40, 3);
    go
     
    update bigtable set col2 = replicate('a', 8000)
    where id = 1;
    go
     
    dbcc page ('newdatatype', 1, 40, 3);
    go
     
    update bigtable set col2 = replicate('b', 4000)
    where id = 2;
    go
     
    dbcc extentinfo ('newdatatype', 'bigtable');
    go
     
    dbcc page ('newdatatype', 1, 40, 3);
    go
     
    dbcc page ('newdatatype', 1, 80, 3); --forwarding 됐다.
    go