30.06.2013 Views

SQL Server Backup and Restore - Simple Talk

SQL Server Backup and Restore - Simple Talk

SQL Server Backup and Restore - Simple Talk

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 9: File <strong>and</strong> Filegroup <strong>Backup</strong> <strong>and</strong> <strong>Restore</strong><br />

Common Filegroup Architectures<br />

A filegroup is simply a logical collection of one or more database files. So far in this book,<br />

our database creation statements have been very straightforward, <strong>and</strong> similar in layout to<br />

the one shown in Listing 9-1.<br />

CREATE DATABASE [File<strong>Backup</strong>sTest] ON PRIMARY<br />

( NAME = N'File<strong>Backup</strong>sTest'<br />

, FILENAME = N'C:\<strong>SQL</strong>Data\File<strong>Backup</strong>sTest.mdf'<br />

) LOG ON<br />

( NAME = N'File<strong>Backup</strong>sTest_log'<br />

, FILENAME = N'C:\<strong>SQL</strong>Data\File<strong>Backup</strong>sTest_log.ldf'<br />

)<br />

GO<br />

Listing 9-1: A simple database file architecture.<br />

In other words, a single data file in the PRIMARY filegroup, plus a log file (remember that<br />

log files are entirely separate from data files; log files are never members of a filegroup).<br />

However, as discussed in Chapter 1, it's common to create more than one data file per<br />

filegroup, as shown in Listing 9-2.<br />

CREATE DATABASE [File<strong>Backup</strong>sTest] ON PRIMARY<br />

( NAME = N'File<strong>Backup</strong>sTest',<br />

FILENAME = N'C:\<strong>SQL</strong>Data\File<strong>Backup</strong>sTest.mdf'),<br />

( NAME = N'File<strong>Backup</strong>sTest2',<br />

FILENAME = N'D:\<strong>SQL</strong>Data\File<strong>Backup</strong>sTest2.ndf')<br />

LOG ON<br />

( NAME = N'File<strong>Backup</strong>sTest_log',<br />

FILENAME = N'E:\<strong>SQL</strong>Data\File<strong>Backup</strong>sTest_log.ldf'<br />

)<br />

GO<br />

Listing 9-2: Two data files in the PRIMARY filegroup.<br />

298

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!