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.

NAME<br />

This one isn’t quite what it sounds like. It is a name for the file you are defining, but only a logical name —<br />

that is, the name that <strong>SQL</strong> <strong>Server</strong> will use internally to refer to that file. You use this name when you<br />

want to resize (expand or shrink) the database and/or file.<br />

FILENAME<br />

This one is what it sounds like — the physical name on the disk of the actual operating system file in<br />

which the data and log (depending on what section you’re defining) will be stored. The default here<br />

(assuming you used the simple syntax you looked at first) depends on whether you are dealing with the<br />

database itself or the log. By default, your file will be located in the \Data subdirectory under your main<br />

\Program Files\<strong>Microsoft</strong> <strong>SQL</strong> <strong>Server</strong>\MS<strong>SQL</strong>10.MS<strong>SQL</strong>SERVER\MS<strong>SQL</strong> directory (or whatever you<br />

called your main <strong>SQL</strong> <strong>Server</strong> directory if you changed it at install). If we’re dealing with the physical database<br />

file, it will be named the same as your database with an .mdf extension. If we’re dealing with the log, it<br />

will be named the same as the database file but with a suffix of _Log and an .ldf extension. You are allowed<br />

to specify other extensions if you explicitly name the files, but I strongly encourage you to stick with the<br />

defaults of mdf (database) and ldf (log file). As a side note, secondary files have a default extension of .ndf.<br />

Keep in mind that, while FILENAME is an optional parameter, it is optional only as long as you go with<br />

the extremely simple syntax (the one that creates a new database based on the model database) that I<br />

introduced first. If you provide any of the additional information, then you must include an explicit file<br />

name — be sure to provide a full path.<br />

SIZE<br />

No mystery here. It is what it says — the size of the database. By default, the size is in megabytes, but<br />

you can make it kilobytes by using a KB instead of MB after the numeric value for the size, or go bigger<br />

by using GB (gigabytes) or even TB (terabytes). Keep in mind that this value must be at least as large as<br />

the model database is and must be a whole number (no decimals) or you will receive an error. If you do<br />

not supply a value for SIZE, then the database will initially be the same size as the model database.<br />

MAXSIZE<br />

Chapter 5: Creating and Altering Tables<br />

<strong>SQL</strong> <strong>Server</strong> allows you to store your database in multiple files; furthermore, it allows<br />

you to collect those files into logical groupings called filegroups. The use of filegroups<br />

is a fairly advanced concept and is outside the scope of this book.<br />

This one is still pretty much what it sounds like, with only a slight twist vs. the SIZE parameter. <strong>SQL</strong><br />

<strong>Server</strong> has a mechanism to allow your database to automatically allocate additional disk space (to grow)<br />

when necessary. MAXSIZE is the maximum size to which the database can grow. Again, the number is, by<br />

default, in megabytes, but like SIZE, you can use KB, GB, or TB to use different increment amounts. The<br />

slight twist is that there is no firm default. If you don’t supply a value for this parameter, then there is<br />

considered to be no maximum — the practical maximum becomes when your disk drive is full.<br />

If your database reaches the value set in the MAXSIZE parameter, your users will start getting errors back<br />

saying that their inserts can’t be performed. If your log reaches its maximum size, you will not be able to<br />

119

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

Saved successfully!

Ooh no, something went wrong!