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.

deprecates the older sp_attach_db functionality and has the advantage of access to as many as 32,000+<br />

files — sp_attach_db is limited to 16.<br />

If you use FOR ATTACH, you must complete the ON PRIMARY portion of the file location information.<br />

Other parts of the CREATE DATABASE parameter list can be left off as long as you are attaching the database<br />

to the same file path they were in when they were originally detached.<br />

WITH DB CHAINING ON|OFF<br />

Hmmm. How to address this one in a beginning kinda way . . .. Well, suffice to say this is a toughie, and<br />

is in no way a “beginning” kind of concept. With that in mind, here’s the abridged version of what this<br />

relates to.<br />

As previously mentioned, the concept of “schemas” didn’t really exist in prior versions of <strong>SQL</strong> <strong>Server</strong>.<br />

Instead, we had the notion of “ownership.” One of the bad things that could happen with ownership<br />

was what are called ownership chains. This was a situation where person A was the owner of an object,<br />

and then person B became the owner of an object that depended on person A’s object. You could have<br />

person after person create objects depending on other people’s objects, and there became a complex<br />

weave of permission issues based on this.<br />

This switch is about respecting such ownership chains when they cross databases (person A’s object is<br />

in DB1, and person B’s object is in DB2). Turn it on, and cross database ownership chains work — turn it<br />

off, and they don’t. Avoid such ownership chains as if they were the plague — they are a database equivalent<br />

to a plague, believe me!<br />

TRUSTWORTHY<br />

This switch is new to add an extra layer of security around access to system resources and files outside of<br />

the <strong>SQL</strong> <strong>Server</strong> context. For example, you may run a .NET assembly that touches files on your network —<br />

if so, you must identify the database that the assembly is part of as being Trustworthy.<br />

By default this is turned off for security reasons — be certain you understand exactly what you’re doing<br />

and why before you set this to on.<br />

Building a Database<br />

At this point, we’re ready to begin building our database. Following is the statement to create it, but<br />

keep in mind that the database itself is only one of many objects that we will create on our way to a fully<br />

functional database:<br />

CREATE DATABASE Accounting<br />

ON<br />

(NAME = 'Accounting',<br />

FILENAME = 'C:\Program Files\<strong>Microsoft</strong> <strong>SQL</strong><br />

<strong>Server</strong>\MS<strong>SQL</strong>10.MS<strong>SQL</strong>SERVER\MS<strong>SQL</strong>\DATA\AccountingData.mdf',<br />

SIZE = 10,<br />

MAXSIZE = 50,<br />

FILEGROWTH = 5)<br />

LOG ON<br />

(NAME = 'AccountingLog',<br />

FILENAME = 'C:\Program Files\<strong>Microsoft</strong> <strong>SQL</strong><br />

<strong>Server</strong>\MS<strong>SQL</strong>10.MS<strong>SQL</strong>SERVER\MS<strong>SQL</strong>\DATA\AccountingLog.ldf',<br />

SIZE = 5MB,<br />

Chapter 5: Creating and Altering Tables<br />

121

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

Saved successfully!

Ooh no, something went wrong!