Quick Check
1. What are the types of fi les that you create for databases and what are the
2. What is the purpose of the transaction log?
Quick Check Answers
1. You can create data and log fi les for a database. Data fi les commonly have either
2. The transaction log records every change that occurs within a database to persist

#1 创建数据库

CREATE DATABASE TK432 ON 

PRIMARY
(NAME = N'TK432_Data', FILENAME = N'c:\test\TTK432.mdf', SIZE = 8MB, MAXSIZE = UNLIMITED, FILEGROWTH = 16MB),

FILEGROUP FG1
(NAME = N'TK432_Data2', FILENAME = N'c:\test\TTK432.Ndf', SIZE = 8MB, MAXSIZE = UNLIMITED, FILEGROWTH = 16MB),

FILEGROUP Documents CONTAINS FILESTREAM DEFAULT
(NAME = N'Documents', FILENAME = N'c:\test\TTK432Documents')

LOG ON
(NAME = N'TK43_Log', FILENAME = N'c:\test\TTK432.ldf', SIZE = 8MB, MAXSIZE = 2048GB, FILEGROWTH = 16MB)

 

Msg 5591, Level 16, State 1, Line 1
FILESTREAM feature is disabled.

To enable FILESTREAM feature:

 http://msdn.microsoft.com/en-us/library/cc645923(v=SQL.100).aspx

EXEC sp_configure filestream_access_level, 2
RECONFIGURE
ALTER DATABASE TK432
MODIFY FILEGROUP FG1 DEFAULT
GO

Lesson 2: Configuring Database Options

Quick Check
1. How do you restrict database access to members of the db_owner role and
2. What backups can be executed for a database in each of the recovery models?
Quick Check Answers
1. You would execute the following command: ALTER DATABASE <database name>
2. You can create full, differential, and fi le/fi legroup backups in the Simple recovery
model. The Bulk-logged recovery model allows you to execute types of backups,
but you cannot restore a database to a point in time during an interval when a
minimally logged transaction is executing. All types of backups can be executed
in the Full recovery model.

R

E

C

O

V

E

R

Y

BACKUP TYPE
  FULL DIFERRENTIAL TRAN LOG
FULL Yes   Yes  Yes
BULK Yes Yes Yes/No
SIMPLE Yes Yes No

 

 

 

 

 

 

 

 

 

ALTER DATABASE AdventureWorks2008R2
SET RECOVERY FULL
GO

 Lesson Summary
You can set the recovery model for a database to Full, Bulk-logged, or Simple.
You can back up transaction logs for a database in the Full or Bulk-logged recovery
model.
The AUTO_SHRINK option shrinks a database fi le when there is more than 25 percent
of free space in the fi le.
You can track and log damaged pages by enabling the PAGE_VERIFY CHECKSUM option.

Lesson 3: Maintaining Database Integrity

After this lesson, you will be able to :
Check a database for integrity
Use DMVs to diagnose corruption issues

Quick Check
1. Which option should be enabled for all production databases?
2. What checks does DBCC CHECKDB perform?

Quick Check Answers
1. You should set the PAGE_VERIFY CHECKSUM option for all production databases.
2. DBCC CHECKDB checks the logical and physical integrity of every table, index,
and indexed view within the database, along with the contents of every indexed
view, page allocations, Service Broker data, and database catalog.

DBCC CHECKDB [( 'database_name' | database_id | 0
[ , NOINDEX | { REPAIR_ALLOW_DATA_LOSS | REPAIR_FAST
| REPAIR_REBUILD } ] )]
[ WITH {[ ALL_ERRORMSGS ] [ , [ NO_INFOMSGS ] ] [ , [ TABLOCK ] ]
[ , [ ESTIMATEONLY ] ] [ , [ PHYSICAL_ONLY ] ] | [ , [ DATA_PURITY ] ] } ]

 

DBCC CHECKDB ('AdventureWorks') WITH NO_INFOMSGS, ALL_ERRORMSGS
GO

Lesson Summary
􀁑 The PAGE_VERIFY CHECKSUM option should be enabled for every production database
to detect any structural integrity errors.
􀁑 When a corrupt page is encountered, the page is logged to the suspect_pages table in
the msdb database. If a database is participating in a Database Mirroring session, SQL
Server automatically retrieves a copy of the page from the mirror, replaces the page on
the principal, and logs an entry in the sys.dm_db_mirroring_auto_page_repair view.
􀁑 DBCC CHECKDB is used to check the logical and physical consistency of a database.

posted on 2012-12-15 15:57  逝者如斯(乎)  阅读(316)  评论(0编辑  收藏  举报