SQL Server 2008读书笔记(2):数据库的配置和维护
2012-12-15 15:57
316 查看
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 创建数据库
To enable FILESTREAM feature:
http://msdn.microsoft.com/en-us/library/cc645923(v=SQL.100).aspx
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.
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.
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.
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.
相关文章推荐
- 数据库开发基本操作-配置SQL Server 2005 Express的身份验证方式,以及如何启用sa登录名
- SQL SERVER实践应用--数据库邮件配置
- SQL Server:高效维护数据库的关键技巧[转摘Tech.Net]
- 第三篇——第二部分——第五文 配置SQL Server镜像——域环境SQL Server镜像日常维护
- 使用sql维护数据库(SQL SERVER)
- 如何配置一个安全稳定的SQL SERVER的数据库
- 解SQL Server“数据库维护计划”
- SQL Server 2008 数据库镜像部署实例之三 配置见证服务器
- 使用SQL Server维护计划实现数据库定时自动备份
- FAQ_SQL Server 2005数据库邮件配置
- SQL Server跨数据库访问及分布式事务的使用及配置
- 【SQL Server学习笔记】数据库对象维护、对象依赖
- SQL Server-高效维护数据库的关键技巧
- 安装SQL Server 数据库时注意事项及优化SQL Server 数据库服务器配置
- [转]Sql Server 主从数据库配置
- SQL SERVER 2008配置Database Mail –用SQL 数据库发邮件
- SQL Server 数据库维护计划 日志作业失败的解决
- 在 VMWare 中配置 SQL Server 2005 N + 1 群集 (五) SQL Server 群集维护
- 在 SQL Server 2005/2008 中,使用 Gmail 帐号配置数据库邮件功能
- c#Winform程序调用app.config文件配置数据库连接字符串 SQL Server文章目录 浅谈SQL Server中统计对于查询的影响 有关索引的DMV SQL Server中的执行引擎入门 【译】表变量和临时表的比较 对于表列数据类型选择的一点思考 SQL Server复制入门(一)----复制简介 操作系统中的进程与线程