<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>data_files - Techyaz.com</title>
	<atom:link href="https://techyaz.com/tag/data_files/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>Tips, Tutorials and How-to Topics</description>
	<lastBuildDate>Sun, 06 May 2018 10:29:56 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.1</generator>

<image>
	<url>https://techyaz.com/wp-content/uploads/2017/11/cropped-Site-icon-150x150.png</url>
	<title>data_files - Techyaz.com</title>
	<link></link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>How to Change Database Default Locations in SQL Server?</title>
		<link>https://techyaz.com/sql-server/change-database-default-locations-sql-server/</link>
					<comments>https://techyaz.com/sql-server/change-database-default-locations-sql-server/#respond</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Thu, 03 May 2018 11:16:42 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server Administration]]></category>
		<category><![CDATA[data file]]></category>
		<category><![CDATA[data_files]]></category>
		<category><![CDATA[database property]]></category>
		<category><![CDATA[log files]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=2215</guid>

					<description><![CDATA[<p>Sometimes, we need to change default database File locations to some other path in SQL Server. If you have configured SQL Server default database file location as drive C then all SQL Server databases will be created in the path&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/change-database-default-locations-sql-server/">How to Change Database Default Locations in SQL Server?</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Sometimes, we need to change default database File locations to some other path in SQL Server. If you have configured SQL Server default database file location as drive C then all SQL Server databases will be created in the path set as database default locations if you have not mentioned their specific drives during database creation. You might need to change this path as per your environment standard. Here, I am going to show you how to view or change database default location in SQL Server.</p>
<p>One thing we should always keep in mind that if we change database default path in SQL Server then it will not change or move the database file locations for your existing databases. If you want to move all existing databases or you want to change database files path to the new location then you need to manually do it for each database.</p>
<p>Once you will change default database file locations then all databases you will create on that SQL Server Instance will be created on new location. Suppose your existing SQL Server default database location is set in C drive and now you have decided to change it to D drive for data files and F drive for Log files then all databases you will create post this change will be created in these both drives. If you will mention any other specific drive during database creation then SQL Server uses that drive and not these database default locations. The SQL Server data file will be created in D drive and log file will be created in F drive but all the existing databases that were created earlier in C drive will not move to new SQL server database file location. If you want to move these databases or want to change database files location then you need to manually do it either by detach-attach method or by ALTER statement.</p>
<h3><span style="color: #333399;">Change Database Default Locations in SQL Server</span></h3>
<p>It&#8217;s very simple method to change default log file location or default data file location in SQL Server. Let’s start to change default database path in SQL Server.</p>
<ul>
<li>Launch SQL Server Management Studio and connect to your SQL Server Instance for which you must change default log file location or default data file location in SQL Server.</li>
<li>Now right click at SQL Server Instance node and choose Properties option.</li>
<li>You will get server properties window on your screen. Click at “Database Settings” from left side pane. You will get all server level details for SQL Server databases in right side pane. Look at the database default locations option given bottom of the right-side pane. Here you can see separate default location for data files, Log file and backup files.</li>
</ul>
<p><img fetchpriority="high" decoding="async" class="size-full wp-image-2216 aligncenter" src="http://techyaz.com/wp-content/uploads/2018/05/default-db-path-min.png" alt="Change Default database file location in SQL Server" width="693" height="631" srcset="https://techyaz.com/wp-content/uploads/2018/05/default-db-path-min.png 693w, https://techyaz.com/wp-content/uploads/2018/05/default-db-path-min-300x273.png 300w" sizes="(max-width: 693px) 100vw, 693px" /></p>
<ul>
<li>You can see database default locations for each file are showing in C drive. It means every database that will be created without mentioning their data or log file location will go to above given SQL Server database default locations.</li>
<li>To change database default path, you need to browse current database default locations for each file to new the new location. Click at three dots showing next to data file or log file locations and then select the new path.</li>
<li>Repeat same exercise for each file. To change default data file location, click at three dots next to data path and select new path here. Similarly, click at three dots next to log file location to change default log file location. If you want to change default backup file location then do the same for backup location as well.</li>
<li>Click ak Ok button once you made changes for desired database file locations.</li>
<li>Last step is to restart SQL Server services to apply this change and bring it into effect.</li>
</ul>
<p>Once you will restart SQL Server services, your SQL Server default database location will be changed to the new path. I hope you like this article. Please follow our <a href="https://www.facebook.com/Techyaz/">Facebook</a> page and <a href="https://twitter.com/Tech_yaz">Twitter</a> handle to get latest updates.</p>
<p><span style="color: #800000;"><em><strong>Read More:</strong></em></span></p>
<ul>
<li><strong><a href="http://techyaz.com/sql-server/get-total-virtual-log-files/" target="_blank" rel="noopener">Get Total Number of Virtual Log Files in SQL Server Transaction Log File</a></strong></li>
<li><strong><a href="http://techyaz.com/sql-server/troubleshooting/fix-error-1105/" target="_blank" rel="noopener">SQL Server Error 1105: Could Not Allocate Space for Object in Database because the filegroup is full</a></strong></li>
<li><strong><a href="http://techyaz.com/sql-server/troubleshooting/change-sql-server-instance-name/" target="_blank" rel="noopener">How to Change SQL Server Instance Name?</a></strong></li>
<li><strong><a href="http://techyaz.com/sql-server/always-turn-off-database-auto-shrink/" target="_blank" rel="noopener">Why Should You Always Turn Off Database Auto Shrink Property?</a></strong></li>
</ul>
<p>&nbsp;</p>
<p>The post <a href="https://techyaz.com/sql-server/change-database-default-locations-sql-server/">How to Change Database Default Locations in SQL Server?</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/change-database-default-locations-sql-server/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Fix Error 1101: Could not allocate a new page for database</title>
		<link>https://techyaz.com/sql-server/troubleshooting/fix-error-1101-could-not-allocate-a-new-page-for-database/</link>
					<comments>https://techyaz.com/sql-server/troubleshooting/fix-error-1101-could-not-allocate-a-new-page-for-database/#respond</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Fri, 23 Mar 2018 13:20:48 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server Administration]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[autogrow]]></category>
		<category><![CDATA[autogrowth setting]]></category>
		<category><![CDATA[data file autogrow]]></category>
		<category><![CDATA[data_files]]></category>
		<category><![CDATA[database property]]></category>
		<category><![CDATA[log space]]></category>
		<category><![CDATA[log_files]]></category>
		<category><![CDATA[space issues]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=1987</guid>

					<description><![CDATA[<p>We get error 1101 because of space issues. Database engine doesn’t able to allocate new pages to the database because of insufficient disk space. The error details are given below: Error: 1101, Severity: 17, State: 2 Could not allocate a&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/troubleshooting/fix-error-1101-could-not-allocate-a-new-page-for-database/">Fix Error 1101: Could not allocate a new page for database</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>We get error 1101 because of space issues. Database engine doesn’t able to allocate new pages to the database because of insufficient disk space. The error details are given below:</p>
<p><em><span style="color: #ff0000;">Error: 1101, Severity: 17, State: 2</span></em><br />
<em><span style="color: #ff0000;"> Could not allocate a new page for database ‘DBNAME&#8217; because of insufficient disk space in filegroup &#8216;PRIMARY&#8217;. Create the necessary space by dropping objects in the filegroup, adding additional files to the filegroup, or setting autogrowth on for existing files in the filegroup.</span></em></p>
<p>There is another error 1105 that is also very much like above error code. Error 1105 can also be fixed using same solution given in this article.</p>
<h3><span style="color: #333399;">Error 1101 &#8211; Root Cause</span></h3>
<p>Main reason behind error 1101 or error 1105 is the insufficient disk space in filegroup/files. You might also get this error if your database drives are running out of space. There are multiple reasons that can cause this error to generate. Some of them are given below.</p>
<ul>
<li>You have restricted database maximum file size or put size limits for files.</li>
<li>Database file drives are running out of space.</li>
<li>Autogrowth is not enabled for database files.</li>
</ul>
<h3><span style="color: #333399;">Solutions</span></h3>
<p>To fix this issue we need to make space for database files to grow. Issue might vary depending on the nature of issue mentioned in above section. Sometimes, you might face this issue if maximum size for database files are restricted to some values so whenever database will grow to that point, SQL Server will not allow to allocate any page to that database. Sometimes you might get error 1101 because you don’t have any space on your database drives. Here, I will discuss each case individually and its solution to fix it.</p>
<h5><span style="color: #993300;">Unrestrict or Increase Database File Size Limits</span></h5>
<p>You might have enough space in your database drives but still you can get error 1101 because the maximum file size of database files is limited to some value and that causes not to grow your database beyond that size. You can unrestrict or increase the existing value of maximum file size to some bigger value. We have also an option to set database file size to unlimited size value that means database file will grow till the database file drive limit. Make sure to set appropriate autogrowth size for each database files.</p>
<p>You can set unlimited file size option or increase the value of maximum file size using GUI in SQL Server Management Studio or using ALTER statement.</p>
<ul>
<li>Connect to Database Instance in <strong>SQL Server Management Studio</strong>. Expand <strong>Database</strong> folder.</li>
<li>Right Click on your database and choose <strong>Property window</strong>.</li>
<li>Click on <strong>Files</strong> tab from left side pane in database property window.</li>
<li>Here you can see all database files. Now you can click on three dots given next of database files in “Autogrowth/Maxsize” column. You can see max size is set to a limited value as shown in below screenshot. I have chosen unlimited option and clicked on Ok button.</li>
</ul>
<p><img decoding="async" class="aligncenter wp-image-1991 size-full" src="http://techyaz.com/wp-content/uploads/2018/03/1-SizeLimit-min.jpg" alt="Set Database file size to unlimited" width="394" height="314" srcset="https://techyaz.com/wp-content/uploads/2018/03/1-SizeLimit-min.jpg 394w, https://techyaz.com/wp-content/uploads/2018/03/1-SizeLimit-min-300x239.jpg 300w" sizes="(max-width: 394px) 100vw, 394px" /></p>
<p>Now we will not get any issue if our database drive has enough space.</p>
<h5><span style="color: #993300;">Space in Database Drives</span></h5>
<p>Another possibility for this error is, there might be possibility that your drives on which you have placed your database files are running out of space. If this is the case then you have below 4 options.</p>
<ul>
<li>Add additional database file to different disk where there is enough space.</li>
<li>Move additional/unwanted files from your existing database drives.</li>
<li>Drop/Purge or Move unwanted data (table/indexes)</li>
<li>Add Additional Disk Space</li>
</ul>
<p>Immediate fix of this issue is to add new database file to another drive where you have enough space to run your transactions. You can use below command to add addition database file to another disk.</p>
<pre><strong><span style="color: #0000ff;">USE [master]</span></strong>
<strong><span style="color: #0000ff;">GO</span></strong>
<strong><span style="color: #0000ff;">ALTER DATABASE [DBNAME]</span></strong>
<strong><span style="color: #0000ff;">ADD FILE (NAME = N'NewFileName', FILENAME = N'F:\mssql\data\newdatafile.ndf', SIZE = 100096KB, FILEGROWTH = 10240KB)</span></strong>
<strong><span style="color: #0000ff;">TO FILEGROUP [SECONDARY]</span></strong>
<strong><span style="color: #0000ff;">GO</span></strong></pre>
<p>You can also add new database file in SQL Server Management Studio by launching Database Property Window. Select Files from left side pane and Click on “Add” button showing in below screenshot. Make sure to set autogrowth value carefully for any database file. Also it is recommended to enable IFI – Instant File Initialization to speed up autogrowth process for your databases. Refer to below article to get best value for autogrowth for your database files. You can also read what are the benefits and how to enable IFI &#8211; Instant File Initialization in below article.</p>
<ul>
<li><strong><a href="http://techyaz.com/sql-server/understanding-database-autogrowth-sql-server/" target="_blank" rel="noopener">What Should be the Best Value for database Autogrowth settings?</a></strong></li>
<li><strong><a href="http://techyaz.com/sql-server/instant-file-initialization-enable-on-sql-server-instance/" target="_blank" rel="noopener">How to Enable Instant File Initialization in SQL Server?</a></strong></li>
</ul>
<p><img decoding="async" class="aligncenter wp-image-1993 size-full" src="http://techyaz.com/wp-content/uploads/2018/03/2-SizeLimit.jpg" alt="Add database file using GUI" width="705" height="633" srcset="https://techyaz.com/wp-content/uploads/2018/03/2-SizeLimit.jpg 705w, https://techyaz.com/wp-content/uploads/2018/03/2-SizeLimit-300x269.jpg 300w" sizes="(max-width: 705px) 100vw, 705px" /></p>
<p>You can also have a look at the existing database drives whether there is any unwanted files or older backup files (*.bak) are not stored. Sometimes we run backups into database drives and forgot to delete or move them. Make sure to drop or move all unwanted files to some other location. Database drives should have only database files.</p>
<p>Final and long-term solution is the data purging. Identify the database objects that are not needed and then plan the data removal or data purging process to make space on your database.</p>
<p>We also have an option to extend the database drives as per the data growth. Make sure to plan this activity carefully before deploying it on production servers.</p>
<h5><span style="color: #993300;">Enable Autogrowth</span></h5>
<p>I have already written an article on Database autogrowth property setting. Read attached article to <a href="http://techyaz.com/sql-server/understanding-database-autogrowth-sql-server/" target="_blank" rel="noopener">find out best value for Autogrowth settings</a>.</p>
<p>You might get error 1101 if you have not enabled authogrowth setting for your database files. You need to enable it by launching database property window. You can click on three dots next to each database files in column “Authogrowth/Maxsize” and click at the enable authogrowth checkbox as showing in below screenshot.</p>
<p><img loading="lazy" decoding="async" class="size-full wp-image-1994 aligncenter" src="http://techyaz.com/wp-content/uploads/2018/03/3-Autogrowth-min.jpg" alt="Enable Autogrowth" width="701" height="631" srcset="https://techyaz.com/wp-content/uploads/2018/03/3-Autogrowth-min.jpg 701w, https://techyaz.com/wp-content/uploads/2018/03/3-Autogrowth-min-300x270.jpg 300w" sizes="auto, (max-width: 701px) 100vw, 701px" /></p>
<p>You can also use ALTER statement to enable database autogrowth setting for your database file. Remember, you need to run this ALTER statement for each database file separately.</p>
<p>Run below ALTER command to enable autogrowth for database file.</p>
<pre><span style="color: #008000;"><strong>--Pass logical filename of your database file for under NAME section.</strong></span>
<span style="color: #0000ff;"><strong>ALTER DATABASE [Techyaz] MODIFY FILE ( NAME = N'Techyaz_Data', FILEGROWTH = 10000KB )</strong></span></pre>
<p>Make sure to enable Instant File Initialization to speedup autogrowth operations. Links to enable Instant File Initialization is attached in this article.</p>
<p>If you are facing this issue for tempdb database then you can consider one more option apart from all of the above options. And this option is to restart SQL Server service if it&#8217;s allowed. Keep in mind, SQL Server service restart will cause an outage for few minutes but it will create new tempdb files with initial size and error 1101 will be disappeared. This is not recommended solution because of outage so you should work on long terms solutions.</p>
<p>You can also use above solutions to fix error 1105 that is very much similar to error 1101. I hope you like this article. Please follow our <a href="https://www.facebook.com/Techyaz/">Facebook</a> page and <a href="https://twitter.com/Tech_yaz">Twitter</a> handle to get latest updates.</p>
<p><span style="color: #800000;"><em><strong>Read More:</strong></em></span></p>
<ul>
<li><strong><a href="http://techyaz.com/sql-server/troubleshooting/fix-msg-5144-and-5145-for-long-or-failed-autogrow/" target="_blank" rel="noopener">Fix Error 5144 and Error 5145 for Long or Failed Autogrow of Database Files</a></strong></li>
<li><strong><a href="http://techyaz.com/sql-server/understanding-database-autogrowth-sql-server/" target="_blank" rel="noopener">Understanding Autogrowth Operation in SQL Server Databases</a></strong></li>
<li><strong><a href="http://techyaz.com/sql-server/instant-file-initialization-enable-on-sql-server-instance/" target="_blank" rel="noopener">How to Enable IFI &#8211; Instant File Initialization?</a></strong></li>
<li><strong><a href="http://techyaz.com/sql-server/troubleshooting/manage-transaction-log-file-during-data-load/" target="_blank" rel="noopener">Manage Database Files during huge Data Load</a></strong></li>
</ul>
<p>The post <a href="https://techyaz.com/sql-server/troubleshooting/fix-error-1101-could-not-allocate-a-new-page-for-database/">Fix Error 1101: Could not allocate a new page for database</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/troubleshooting/fix-error-1101-could-not-allocate-a-new-page-for-database/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Understanding SQL Server Data Files, Pages &#038; Extents</title>
		<link>https://techyaz.com/sql-server/understanding-sql-server-data-files-pages-extents/</link>
					<comments>https://techyaz.com/sql-server/understanding-sql-server-data-files-pages-extents/#comments</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Fri, 21 Jul 2017 19:28:22 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[data_files]]></category>
		<category><![CDATA[extent]]></category>
		<category><![CDATA[page]]></category>
		<category><![CDATA[SQL_Server_Architecture]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=256</guid>

					<description><![CDATA[<p>SQL Server data files, pages &#38; extents are very much related to each other. These are architectural terms which are used to store data physically inside the database. First let&#8217;s start with data files then we will understand how data&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/understanding-sql-server-data-files-pages-extents/">Understanding SQL Server Data Files, Pages &#038; Extents</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>SQL Server data files, pages &amp; extents are very much related to each other. These are architectural terms which are used to store data physically inside the database. First let&#8217;s start with data files then we will understand how data files are related to pages and then to extents.</p>
<p><span style="color: #800000;"><em><strong>Related Articles:</strong></em></span></p>
<ul>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/manage-transaction-log-file-during-data-load/" target="_blank" rel="noopener">Manage Transaction Log File during Data Load</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/always-turn-off-database-auto-shrink/" target="_blank" rel="noopener">Why Should You Always Turn Off Database Auto Shrink Property?</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/understanding-database-autogrowth-sql-server/" target="_blank" rel="noopener">What is the Best Value for Database File Autogrowth?</a></strong></li>
<li><strong><a href="https://techyaz.com/interview-questions/sql-server-interview-questions-answers-architecture/" target="_blank" rel="noopener">SQL Server Architecture Interview Questions &amp; Answers</a></strong></li>
</ul>
<h3><span style="color: #000080;"><strong>SQL Server Data Files </strong></span></h3>
<p>When we create any SQL Server database, few operating system files are created and placed in to their respective directories. These files are known as database files. SQL Server databases have three types of files to handle data and log separately.</p>
<ul>
<li>Primary data file</li>
<li>Secondary data files</li>
<li><a href="https://techyaz.com/sql-server/understanding-transaction-log-architecture/" target="_blank" rel="noopener">Log files</a></li>
</ul>
<p>Every database has only one primary data file but none to multiple secondary data files whereas same database has minimum one log file and can have multiple log files depending on the requirements. <a href="https://techyaz.com/sql-server/understanding-transaction-log-architecture/" target="_blank" rel="noopener">Log files</a> hold all the log information that is used to recover the database whereas all data files keeps or stores the actual data of the database.</p>
<p>The recommended file extension for primary, secondary data file and log file are .mdf, .ndf and .ldf respectively although it is not mandatory to keep same extension names but it helps you identify the different kinds of files and their use.</p>
<p>Each database file has two names one is logical file name another one is physical file name. The logical file name is the name used to refer to the physical file in all Transact-SQL statements whereas physical file name is the name that appear on the OS directory path.</p>
<h3><span style="color: #000080;"><strong>Pages &amp; Extents</strong></span></h3>
<p>We read in above section that every database has data files to store actual data. Data stores inside these data files in form of Pages so Page is the fundamental unit of data storage in SQL Server but Log files do not store any data, they contain a series of log records so log files do not have any pages.</p>
<p>The disk space allocated to a data file (.mdf or .ndf) in a database is logically divided into pages numbered contiguously from 0 to n. Pages in a SQL Server data file are numbered sequentially, starting with zero (0) for the first page in the file. Each file in a database has a unique file ID number. To uniquely identify a page in a database, both the file ID and the page number are required.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-large wp-image-258" src="http://techyaz.com/wp-content/uploads/2017/07/Page-Extent-1024x576.jpg" alt="SQL Server page extent data files" width="1024" height="576" srcset="https://techyaz.com/wp-content/uploads/2017/07/Page-Extent-1024x576.jpg 1024w, https://techyaz.com/wp-content/uploads/2017/07/Page-Extent-300x169.jpg 300w, https://techyaz.com/wp-content/uploads/2017/07/Page-Extent-768x432.jpg 768w, https://techyaz.com/wp-content/uploads/2017/07/Page-Extent.jpg 1280w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></p>
<p>The size of page is 8 KB. Each page begins with 96-byte header as shown in above image that is used to store system information about the page. This information includes the page number, page type, the amount of free space on the page, and the allocation unit ID of the object that owns the page.</p>
<p>Data rows are put on the page serially, starting immediately after the header. A row offset table starts at the end of the page, and each row offset table contains one entry for each row on the page. Each entry records how far the first byte of the row is from the start of the page. The entries in the row offset table are in reverse sequence from the sequence of the rows on the page.</p>
<p>Extents are a collection of eight physically contiguous pages and are used to efficiently manage the pages. All pages are stored in extents.</p>
<p>The first page in each file is a file header page that contains information about the attributes of the file. Several of the other pages at the start of the file also contain system information, such as allocation maps. Below are the list of page types used in the data files of a SQL Server database.</p>
<ol>
<li><span style="color: #000080;"><strong>Data: </strong></span>Data Page stores data rows with all data, except large object data types like text, ntext, image, nvarchar(max), varchar(max), varbinary(max), and xml data, when text in row is set to ON.</li>
<li><span style="color: #000080;"><strong>Index:</strong> </span>Stores <a href="https://techyaz.com/sql-server/understanding-sql-server-indexes/" target="_blank" rel="noopener">Index</a> data.</li>
<li><span style="color: #000080;"><strong>Text/Image: </strong></span>Stores large object data types like text, ntext, image, nvarchar(max), varchar(max), varbinary(max), and xml data</li>
<li><span style="color: #000080;"><strong>Global Allocation Map: </strong></span>GAM pages record what extents have been allocated. Each GAM covers 64,000 extents, or almost 4 GB of data. The GAM has one bit for each extent in the interval it covers. If the bit is 1, the extent is free; if the bit is 0, the extent is allocated.</li>
<li style="text-align: left;"><span style="color: #000080;"><strong>Shared Global Allocation Map: </strong></span>SGAM pages record which extents are currently being used as mixed extents and also have at least one unused page. Each SGAM covers 64,000 extents, or almost 4 GB of data.</li>
</ol>
<p style="padding-left: 30px; text-align: left;">The SGAM has one bit for each extent in the interval it covers. If the bit is 1, the extent is being used as a mixed     extent and has a free page. If the bit is 0, the extent is not used as a mixed extent, or it is a mixed extent and all     its pages are being used.</p>
<ol style="text-align: left;" start="6">
<li><span style="color: #000080;"><strong>Page Free Space: </strong></span>Page Free Space (PFS) pages record the allocation status of each page, whether an individual page has been allocated, and the amount of free space on each page. The PFS has one byte for each page, recording whether the page is allocated, and if so, whether it is empty, 1 to 50 percent full, 51 to 80 percent full, 81 to 95 percent full, or 96 to 100 percent full.</li>
</ol>
<p style="padding-left: 30px; text-align: left;">After an extent has been allocated to an object, the Database Engine uses the PFS pages to record which pages     in the extent are allocated or free. This information is used when the Database Engine has to allocate a new           page.</p>
<ol style="text-align: left;" start="7">
<li><span style="color: #000080;"><strong>Index Allocation Map</strong>:</span> Information about extents used by a table or index per allocation unit. When the SQL Server Database Engine has to insert a new row and no space is available in the current page, it uses the IAM and PFS pages to find a page to allocate, or, for a heap or a Text/Image page, a page with sufficient space to hold the row. The Database Engine uses the IAM pages to find the extents allocated to the allocation unit.</li>
<li><span style="color: #000080;"><strong>Bulk Changed Map: </strong></span>Information about extents modified by bulk operations since the last BACKUP LOG statement per allocation unit. This tracks the extents that have been modified by bulk logged operations since the last BACKUP LOG statement.</li>
</ol>
<p style="text-align: left; padding-left: 30px;">If the bit for an extent is 1, the extent has been modified by a bulk logged operation after the last BACKUP LOG   statement. If the bit is 0, the extent has not been modified by bulk logged operations.</p>
<p style="text-align: left; padding-left: 30px;">Although BCM pages appear in all databases, they are only relevant when the database is using the bulk-logged recovery model. In this recovery model, when a BACKUP LOG is performed, the backup process scans the             BCMs for extents that have been modified. It then includes those extents in the log backup. This lets the bulk       logged operations be recovered if the database is restored from a database backup and a sequence of   transaction  log backups.</p>
<p style="text-align: left; padding-left: 30px;"> BCM pages are not relevant in a database that is using the simple recovery model, because no bulk logged  operations are logged. They are not relevant in a database that is using the full recovery model, because that  recovery model treats bulk logged operations as fully logged operations.</p>
<ol style="text-align: left;" start="9">
<li><strong><span style="color: #000080;">Differential Changed Map:</span> </strong>Information about extents that have changed since the last <a href="https://techyaz.com/sql-server/understanding-sql-server-backups/" target="_blank" rel="noopener">BACKUP DATABASE</a> statement per allocation unit. This tracks the extents that have changed since the last BACKUP DATABASE statement.</li>
</ol>
<p style="text-align: left; padding-left: 30px;">  If the bit for an extent is 1, the extent has been modified since the last BACKUP DATABASE statement. If the bit is 0, the extent has not been modified.</p>
<p style="text-align: left; padding-left: 30px;">Differential backups read just the DCM pages to determine which extents have been modified. This greatly reduces the number of pages that a differential backup must scan. The length of time that a differential backup runs is proportional to the number of extents modified since the last BACKUP DATABASE statement and not the overall size of the database.</p>
<h3><span style="color: #000080;"><strong>Sequence of Pages in Data file</strong></span></h3>
<p>A PFS page is the first page after the file header page in a data file (page number 1). This is followed by a GAM page (page number 2), and then an SGAM page (page 3). There is a PFS page approximately 8,000 pages in size after the first PFS page. There is another GAM page 64,000 extents after the first GAM page on page 2, and another SGAM page 64,000 extents after the first SGAM page on page 3. The DCM and BCM pages are located behind the GAM and SGAM pages in a physical file and interval between DCM pages and BCM pages is the same as the interval between GAM and SGAM page, 64,000 extents.</p>
<p>I hope this article helps you to understand data files, pages and extents. The source of this article is <a href="https://msdn.microsoft.com/en-us/library/cc280361.aspx">MSDN Book Online</a>.  If you like this article, you can follow us on our <strong><a href="https://www.facebook.com/Techyaz/" target="_blank" rel="noopener">facebook page</a></strong> and on <strong><a href="https://twitter.com/Tech_yaz" target="_blank" rel="noopener">Twitter</a></strong> handle to get latest updates.</p>
<p>The post <a href="https://techyaz.com/sql-server/understanding-sql-server-data-files-pages-extents/">Understanding SQL Server Data Files, Pages &#038; Extents</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/understanding-sql-server-data-files-pages-extents/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>
