17.06.2013 Views

Beginning Microsoft SQL Server 2008 ... - S3 Tech Training

Beginning Microsoft SQL Server 2008 ... - S3 Tech Training

Beginning Microsoft SQL Server 2008 ... - S3 Tech Training

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

And . . .<br />

Name Fileid Filename Filegroup<br />

Accounting 1 c:\<br />

Program<br />

Files\<br />

<strong>Microsoft</strong><br />

<strong>SQL</strong> <strong>Server</strong>\<br />

MS<strong>SQL</strong>10<br />

.MS<strong>SQL</strong>SERVER<br />

\MS<strong>SQL</strong>\DATA<br />

\Accounting-<br />

Data.mdf<br />

AccountingLog 2 c:\<br />

Program<br />

Files\<br />

<strong>Microsoft</strong><br />

<strong>SQL</strong> <strong>Server</strong>\<br />

MS<strong>SQL</strong>10<br />

.MS<strong>SQL</strong>SERVER<br />

\MS<strong>SQL</strong>\DATA<br />

\Accounting-<br />

Log.ldf<br />

Let’s say you want to change things a bit. For example, let’s say that we know that we are going to be<br />

doing a large import into our database. Currently, our database is only 15MB in size — that doesn’t hold<br />

much these days. Since we have Autogrow turned on, we could just start our import, and <strong>SQL</strong> <strong>Server</strong><br />

would automatically enlarge the database 5MB at a time. Keep in mind, however, that it’s actually a fair<br />

amount of work to reallocate the size of the database. If we were inserting 100MB worth of data, then the<br />

server would have to deal with that reallocation at least 16 times (at 20MB, 25MB, 30MB, and so on).<br />

Since we know that we’re going to be getting up to 100MB of data, why not just do it in one shot? To do<br />

this, we would use the ALTER DATABASE command.<br />

The general syntax looks like this:<br />

Chapter 5: Creating and Altering Tables<br />

PRI-<br />

MARY<br />

Size Maxsize Growth Usage<br />

10240<br />

BK<br />

NULL 5120K<br />

B<br />

51200KB 5120KB data<br />

only<br />

25600KB 5120KB log<br />

only<br />

ALTER DATABASE <br />

ADD FILE<br />

([NAME = ,]<br />

FILENAME = <br />

[, SIZE = ]<br />

[, MAXSIZE = < size in KB, MB, GB or TB >]<br />

[, FILEGROWTH = ]) [,...n]<br />

[ TO FILEGROUP filegroup_name]<br />

[, OFFLINE ]<br />

137

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

Saved successfully!

Ooh no, something went wrong!