Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 4

Before creating and configuring a database, you should have a basic understanding of how SQL Server manages internal

storage. Tables are used to store data in the database, and provide the foundation on which most other database objects depend. Tables are defined with one or more columns. Each table column has a defined data type, which determines what ind of data is stored within the table. !n addition to columns, tables can contain "ero or more rows, each of which represents a hori"ontal line in the table, li e a spreadsheet row. #ows are stored within a page. $ages are on%dis structures, 8KB in size,& '()* bytes+ which contain data rows. $ages also contain header and row offset areas &tabela+. Headers, 96 bytes in si"e, store information about, the page type, amount of free space on the page, and object ID of the table storing rows in it. The row offset table holds one entry for each row on the page. -lthough mada a page ta es up '. of storage, or '()* bytes, the actual space that can be used after the header and row offset storage is 8060 bytes. trenutni prostor /to mo0e biti ori/teno na on header i red offset us ladi/tenje je '121 There are different types of pages,

Data pages are used to hold all table data, e3cept TEXT, NTEXT, and IMAGE data types. nde! pages are used for clustered and nonclustered inde3 storage. Te!t" mage pages contain TEXT, image, and NTEXT data. #ree space pages trac free space available in pages allocated.
$ages are allocated within bloc s, called e!tents. E3tents contain eight contiguous '.B pages, which are allocated to data files. There are two types of e3tents, uniform and mi!ed. $i!ed e3tents share up to ' objects &one object per '.B page+. 4nce an object is big enough to contain eight '.B pages, the pages are switched to a uniform e3tent. %niform e3tents contain a single object. -ll eight '.B pages are dedicated to this object. E3tents also have data pages, which are used to manage meta data 5 data about the e3tents themselves. 4daci o njima samima.

&lobal 'llocation $ap &6-7+ and (econdary &lobal 'llocation $ap &S6-7+
pages contain meta data about e3tents.

nde! 'llocation $ap pages store data about e3tents used by tables or inde3es. Bul) *hanged $ap pages list e3tents changed by bul operations since the last
transaction log bac up was performed. Differential *hanged $ap pages trac e3tents that have changed since the last full database bac up.

Data file Promarni data file mdf Sekundarni data file ndf primary data - MDF This primary data file stores data in tables and indexes and contains the startup information for the database. Sadri sistemske tabele koje spremaju inf. db. Objektima, ukljuujui, file lokaciju informaciju o s im didatnim fajlo ima i lokacijama. !secondar" data files and transaction lo# files$. %ach secondary data file #enerall" has the .NDF filename extension !this extension is also not re&uired$. Secondar" data files se koristi primarno kada se spanaju i'e disko a. are used primaril" (hen a database spans multiple disk dri es. ) lokacije* + master db + primarni file ,a db

- eini sluaje a db en#ine nala,i file lokacija informacije u master db. Izuzetak od o o# pra ila je kada i, r'a am operacije koje u,rokuje db mehani,am ,a kori'tenje file lokacija informaciju na.enu u primarnom fajlu ,a inicijali,aciju file lokacija entries u master ba,i. Te operacije su* up#radin# from S/0 Ser er 1.2 to S/0 Ser er )222, restorin# the master database, attachin# a database to S/0 Ser er )222 usin# the sp3attach3db s"stem stored procedure. Additional data file properties include the file 45, initial file si,e, file #ro(th increment !if an"$, and maximum file si,e. These data file properties are stored in the File Header page, (hich is the first pa#e of each data file. S/0 Ser er uni&uel" identifies pa#es in a data file b" file 45 and pa#e number. Pa#es in a data file are numbered se&uentiall" startin# at ,ero. 5efinin# and alterin# the properties of a data file are co ered in 6hapter 7. S/0 Ser er jedinst eno identificira pa#es u data file od file ID i page number. Stranice u a data file su numeriran u ni,u startin# at nula.

'llocating (pace for Tables and nde!es


8efore S/0 Ser er )222 can store information in a table or an index, free space must be allocated from within unutar a data file and assigned dod el en to that ob ect . Free space is allocated dodjeljen for tables and indexes in units called extents. 9n extent is 7: ;8 of space, consistin# of < conti#uous pa#es, each < ;8 in si,e. ) tipa extenda* mi!ed e!tents and uniform e!tents S/0 Ser er )222 uses mi!ed e!tents ,a spremanje malih i,nosa podatak do < objekata unutar pojedino# extenda. uniform e!tents to store data from a sin#le object. ;ada neki objekt treba dodatni prostor tada "# slobodan prostor je dodjeljen mi!ed extenda $. a kasnije ako treba jo' tada mu se dodjeljuje uniform extent .

=hen an object re&uires additional space, S/0 Ser er )222 allocates free space from mixed extents until an object uses a total of ei#ht pa#es. Thereafter, S/0 Ser er )222 allocates a uniform extent to that object. S/0 Ser er )222 (ill #ro( the data files in a round+robin al#orithm if no free space exists in an" data file and auto#ro( is enabled. =hen S/0 Ser er )222 needs a mixed extent (ith at least one free pa#e, a %econdary &lobal Allocation Map '%&AM( page is used to locate such an extent.
Secondary Global Allocation Map Page (SGAM): An allocation page containing information about mixed extents. The third page of each SQL Server file is a SGAM page. SGAM pages track all mixed extents that have al least one unused page. ne SGAM page can track up to almost 64K of mixed extents! or about 4GB of data.

%ach S>9? pa#e is a bitmap co erin# )*+,,, e!tents !approximatel" * &- $ that is used to identif" allocated mixed extents (ith at least one free pa#e. %ach extent in the inter al that S>9? co ers is assi#ned a bit. The extent is identified as a mixed extent (ith free pa#es (hen the bit is set to ". =hen the bit is set to ,, the extent is either a mixed extent (ith no free pa#es, or the extent is a uniform extent.

.ages and /!tents


The fundamental unit of data stora#e in ?icrosoft@ S/0 Ser erA is the page. 4n S/0 Ser er )222, the page size is 0 1-. This means S/0 Ser er )222 databases ha e "$0 pages per megabyte. The start of each pa#e is a B7+b"te header used to store s"stem information, such as the t"pe of pa#e, the amount of free space on the pa#e, and the object 45 of the object o(nin# the pa#e. The table sho(s ei#ht t"pes of pa#es in the data files of a S/0 Ser er )222 database. .age type 5ata 4ndex TextC4ma#e >lobal 9llocation ?ap, Secondar" >lobal 9llocation ?ap Pa#e Dree Space 4ndex 9llocation ?ap 8ulk 6han#ed ?ap 5ifferential 6han#ed ?ap 2ontents 5ata ro(s (ith all data except text, ntext, and ima#e data. 4ndex entries. Text, ntext, and ima#e data. 4nformation about allocated extents.

4nformation about free space a ailable on pa#es. 4nformation about extents used b" a table or index. 4nformation about extents modified b" bulk operations since the last 896;-P 0O> statement. 4nformation about extents that ha e chan#ed since the last 896;-P 59T989S% statement.

0o# files do not contain pa#esE the" contain a series of lo# records. 5ata pa#es contain all the data in data ro(s except text, ntext, and ima#e data, (hich is stored in separate pa#es. 5ata ro(s are placed seriall" on the pa#e startin# immediatel" after the header. 9 ro( offset table starts at the end of the pa#e. The ro( offset table contains one entr" for each ro( on the pa#e and each entr" records ho( far the first b"te of the ro( is from the start of the pa#e. The entries in the ro( offset table are in re erse se&uence from the se&uence of the ro(s on the pa#e.

Fo(s cannot span pa#es in S/0 Ser er. 4n S/0 Ser er )222, the maximum amount of data contained in a sin#le ro( is <272 b"tes, not includin# text, ntext, and ima#e data. %xtents are the basic unit in (hich space is allocated to tables and indexes. 9n extent is < conti#uous pa#es, or 7: ;8. This means S/0 Ser er )222 databases ha e G7 extents per me#ab"te. To make its space allocation efficient, S/0 Ser er )222 does not allocate entire extents to tables (ith small amounts of data. S/0 Ser er )222 has t(o t"pes of extents* -niform extents are o(ned b" a sin#le objectE all ei#ht pa#es in the extent can onl" be used b" the o(nin# object. ?ixed extents are shared b" up to ei#ht objects. 9 ne( table or index is usuall" allocated pa#es from mixed extents. =hen the table or index #ro(s to the point that it has ei#ht pa#es, it is s(itched to uniform extents. 4f "ou create an index on an existin# table that has enou#h ro(s to #enerate ei#ht pa#es in the index, all allocations to the index are in uniform extents.

7anage 8our $rofile 9Legal 9:ontact ;s 97S<= >lash =ewsletter ? *112 7icrosoft :orporation. -ll rights reserved

You might also like