목차

Lesson 1: Planning Databases

How Is Data Stored?

How the Transaction Log Works

  1. Data modification is send by application
  2. Data pages are located in, or read into, buffer cache and modified
  3. Modification is recorded in transaction log on disk
  4. Checkpoint writes committed transactions to database

Considerations for File Placement

What Are Filegroups?

Filegroups are named collections of files, and are used to simplify data placement

Considerations for Creating Filegroups

Considerations for Capacity Planning

Estimating the size of a database

Lesson 2: Creating Databases

Considerations for Creating Databases

Syntax for Creating Databases

CREATE DATABASE database_name
[ ON
[ PRIMARY ]  [ filespec [, n] ]
[ FILEGROUP filegroup_name [DEFAULT] ]
  filespec [, n]  ] [, n] ]
[ LOG ON
  [filespec [, n] ]
[ COLLATE collation_name ]

:!: DB정보 보기

EXEC sp_helpdb database_name

How to Resize Database Files

What Are Schemas?

A schema is a namespace for database objects.
Every database contains a schema called dbo. The dbo schema is the default schema for all users who do not have an explicitly defined default schema.

Syntax for Creating Schemas

CREATE SCHEMA
schema_name | AUTHORIZATION owner_name |
  schema_name AUTHORIZATION owner_name
[ table_definition | view_definition |
  grant_statement | revoke_statement |
  deny_statement ]

:!: 스키마 정보 보기

1) SELECT * FROM SYS.SCHEMAS
2) SELECT DISTINCT TABLE_SCHEMA FROM INFORMATION_SCHEMA.TABLES
3) SELECT TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME, COLUMN_DEFAULT
   FROM INFORMATION_SCHEMA.COLUMNS

How Object Name Resolution Works

SQL Server 2005 uses the following process to resolve an unqualified object name:

Lesson 3: Managing Databases

Database Options

Set database options by using:

^ Option ^ Category Purpose ^

Automatic Controls automatic behaviors such as statistics, database closing, and shrinking
Availability Controls whether database is online, who can connect to it, and whether database is read-only
Cursor Controls cursor bahavior and scope
Recovery Controls the recovery model for the database
SQL Controls ANSI compliance options such as ANSI nulls and recursive triggers

:!: 싱글유저 모드로 전환하기 (OFFLINE을 하기전에 실행한다. 이 작업을 수행하지 않으면 OFFLINE이 무척이나 오래걸리게 된다.)

ALTER DATABASE Sample SET SINGLE_USER
WITH ROLLBACK AFTER 60;

Sources of Database Metadata

Information Source Description
SQL Server Management Studio Visual tool that generates reports displaying server and database metadata
Catalog views Provide metadata about database objects returning rows of information
Metadata functions Return a single value of metadata information per function
System stored procedures Retrieve metadata using stored procedures