The Real MCTS SQL Server 2008 Exam 70-432 Prep Kit: Database Implementation and Maintenance
Copyright Page
Technical Editor
Lead Authors
Contributing Authors
Contents
Chapter 1: MCTS SQL Server 2008 Exam 432 New Features in SQL Server 2008
Introduction
A Word About the Test
New Feature Overview
Installation
Compressed Backups
Enhanced Configuration and Management of Audits
New Table Value Parameter
FileStream Data Types
Sparse Column Support
Encryption Enhancements
Key Management and Encryption
High Availability
Performance
Performance Data Management
Resource Governor (similar to Query Governor)
Freeze Plan
SQL Server 2008 Declarative Management Framework
Development Improvements
LINQ Support
MERGE Statement
Spatial Data Type
Analysis Services Improvements
ETL/SSIS Enhancements
Reporting Services
No Longer Requires IIS
Better Graphing
Export to Word Support
Deprecated Features
Discontinued Features
Summary of Exam Objectives
Exam Objectives Fast Track
Exam Objectives Frequently Asked Questions
Self Test
Self Test Quick Answer Key
Chapter 2: MCTS SQL Server 2008 Exam 432 Installing SQL Server 2008
Introduction
SQL Versions, Requirements, Features, and Differences
Planning Your Installation
Upgrade Tools
Hardware Requirements: CPU, Memory, and Disk
Operating System Requirements
Software Requirements
Establishing Service Accounts
Upgrading vs. Side-by-Side Installation
Clustered Installation Considerations
Unattended Installations
Post-Upgrade Activity
Database Instances, Files, Locations, Filegroups, and Performance
Binary File Locations
Filegroups
Disk Planning Best Practices
Summary of Exam Objectives
Exam Objectives Fast Track
Exam Objectives Frequently Asked Questions
Self Test
Self Test Quick Answer Key
Chapter 3: MCTS SQL Server 2008 Exam 432 Configuring SQL Server 2008
Introduction
Instances vs. Default Instance
Instance Limitations
Performance Considerations
SQL Server Configuration Manager
Managing Services
Enabling FileStream
Managing Connections and Protocols
Shared Memory
Named Pipes
VIA
TCP/IP
Changing the TCP Port
Aliases
sp_configure and SQL Server Management Studio
Advanced Options
AWE
Setting the Maximum and Minimum Memory for SQL Server
Max Server Memory (MB)
Min Server Memory (MB)
Maximum Degree of Parallelism
Security Certifications
C2 Auditing
Common Criteria Compliance
New Features
Backup Compression Default
FileStream Access Level
Database Mail
Configuring Database Mail
Full-Text Indexing
Configuring Full-Text Indexing
Managing Full-Text Indexes
Summary of Exam Objectives
Exam Objectives Fast Track
Exam Objectives Frequently Asked Questions
Self Test
Self Test Quick Answer Key
Chapter 4: MCTS SQL Server 2008 Exam 432 Managing Security
Introduction
Principals
Roles
The “Principle of Least Privilege”
Users
Schemas
Users versus Logins
Authentication Mode
Permissions
Cross-Database Ownership Chaining
Object Permissions
Log-in Permissions (As Related to Roles)
Auditing
Change Data Capture (CDC)
Using DDL Triggers
The SQL Server Configuration Manager
Security and SQL Agent
Service Accounts and Permissions
Domain Service Accounts versus Local Service Accounts
Summary of Exam Objectives
Exam Objectives Fast Track
Exam Objectives Frequently Asked Questions
Self Test
Self Test Quick Answer Key
Chapter 5: MCTS SQL Server 2008 Exam 432 Managing Data Encryption
Introduction
Understanding Transparent Data Encryption
Requirements
Enabling TDE
How Data Is Encrypted
Encryption Keys
Key Management
Database Encryption Keys
Best Practices for Managing Database Keys
Cell- and Column-Level Encryption
EFS Encryption (Through the Operating System)
EFS in a Clustered Environment
Restoring Encrypted Backups to Another Server or Instance
Third-Party Encryption Tools
Summary of Exam Objectives
Exam Objectives Fast Track
Exam Objectives Frequently Asked Questions
Self Test
Self Test Quick Answer Key
Chapter 6: MCTS SQL Server 2008 Exam 432 Managing High Availability
Introduction
Defining High Availability
SQL High-Availability Options
Log Shipping
Mirroring
Clustering
Special Hardware Requirements
Special Software Requirements
Geo-Clustering
Replication
Recovery Model
Expandability
Hot Add CPU
Hot Add Memory
Summary of Exam Objectives
Exam Objectives Fast Track
Exam Objectives Frequently Asked Questions
Self Test
Self Test Quick Answer Key
Chapter 7: MCTS SQL Server 2008 Exam 432 Maintaining Your Database
Introduction
Understanding Data Collation
SQL Server Collations
Binary Collations
Using Collations
Collation Considerations for Backup and Restore
Maintaining Data Files
Implementing Data Compression
Row versus Page Compression
Estimating Space Savings Using sp_estimate_data_compression_savings
Using Sparse Columns
Maintaining Indexes
DBCC Explained
Using DBCC CHECKTABLE to Verify Table Integrity
Using the DBCC CHECKDB to Verify Database Integrity
Using the DBCC SHRINKFILE Option to Reclaim Database Space
Backing Up and Restoring Data
Understanding Database Recovery Models
Backup Types
Choosing a Database Backup Strategy
Restoring Databases
Performing Online Restore
Restoring Individual Pages
Performing Ongoing Maintenance
Using SQL Server Agent
Using Database Maintenance Plans
Policy-Based Management
Examples of Using Policy-Based Management
Using the Data Collector to Collect Performance Data
Summary of Exam Objectives
Exam Objectives Fast Track
Exam Objectives Frequently Asked Questions
Self Test
Self Test Quick Answer Key
Chapter 8: MCTS SQL Server 2008 Exam 432 ETL Techniques
Introduction
Understanding ETL
Bulk Copying Data
Using BCP
Using BCP Data File Types
Using Format Files
Using the BULK INSERT Statement
Recovery Model and Bulk Operations
Optimizing Bulk Load Performance
Distributed Queries
Understanding Fully Qualified Object Names
Enabling Ad Hoc Distributed Queries
Using the OPENROWSET Function
Querying Data with OPENROWSET
Modifying Data with OPENROWSET
Copying Data with OPENROWSET
Using OPENROWSET (BULK,…)
Using the OPENDATASOURCE Function
Using Linked Servers
Using the OPENQUERY Function
Using Distributed Transactions
SQL Server Integration Services
Creating SSIS Packages
Using the Copy Database Wizard
Using the Import and Export Wizard
Using Business Intelligence Development Studio
Using Package Configurations
Managing SSIS
Understanding SSIS Package Storage
Deploying SSIS Packages
Securing SSIS Packages
Using Package Protection Levels
MSDB Database Roles and SSIS Package Roles
Executing SSIS Packages
Logging Package Execution
Alternative ETL Solutions
Coding Solutions
Third-Party Solutions
Summary of Exam Objectives
Exam Objectives Fast Track
Exam Objectives Frequently Asked Questions
Self Test
Self Test Quick Answer Key
Chapter 9: MCTS SQL Server 2008 Exam 432 Managing Replication
Introduction
Replication Scenarios
Article
Publication
Subscription
Publisher
Distributor
Subscriber
Replication Types
Snapshot
Components
Transactional
Components
Updatable Subscription
Peer-to-Peer Replication
Merge
Components
Replication Configuration
Configuration of Distributor
Configuration of Publisher
Configuration of Subscriber(s)
Configuration of Peer-to-Peer Replication
Conflict Resolution
Conflict Resolution Mechanism in Peer-to-Peer Replication
DDL Replication
Security Considerations
Snapshot Agent
Connect to Publisher
Replication Performance
Monitoring
Replication Monitor
Tracer Tokens
Alerts
Performance Monitor
Replication Agents
Replication Distribution
Replication Logread
Replication Merge
Replication Snapshot
DMVs
Summary of Exam Objectives
Exam Objectives Fast Track
Exam Objectives Frequently Asked Questions
Self Test
Self Test Quick Answer Key
Chapter 10: MCTS SQL Server 2008 Exam 432 Monitoring and Troubleshooting
Introduction
Service Troubleshooting
Concurrency Issues
Agent Issues
Error Logs
Windows Event Log
SQL Server Log
SQL Server Profiler
Performance Monitor
Summary of Exam Objectives
Exam Objectives Fast Track
Exam Objectives Frequently Asked Questions
Self Test
Self Test Quick Answer Key
Chapter 11: MCTS SQL Server 2008 Exam 432 SQL Server XML Support
Introduction
Working with XML Data
Understanding XML Indexing
HTTP Endpoints
Http Endpoints Defined
Endpoint Can Interface to a Stored Procedure
How to Create the Endpoint
Web Services
XQuery Explained
XPath
Summary of Exam Objectives
Exam Objectives Fast Track
Exam Objectives Frequently Asked Questions
Self Test
Self Test Quick Answer Key
Chapter 12: MCTS SQL Server 2008 Exam 432 Service Broker
Introduction
The Queuing Concept Explained
Service Broker Defined
Message Types
Contracts
Queues
Services
Endpoints
Routes
Sending a Message
Summary of Exam Objectives
Exam Objectives Fast Track
Exam Objectives Frequently Asked Questions
Self Test
Self Test Quick Answer Key
Chapter 13: MCTS SQL Server 2008 Exam 432 Performance Tuning
Introduction
Tracing
Trace Templates
Trace Events
Trace Filters
Server-Side Tracing
Combining System Monitor and Profiler Traces
Replaying Traces
Using SQLDiag to Collect Performance Data
Locks, Blocking, and Deadlocks
Locking
Blocking
Deadlocks
Transaction Isolation Levels
Lock Escalation
Lock Compatibility
Detecting and Resolving Locking Problems
Guide to the DYNAMIC Management Views (DMVs)
Partitioning
Horizontal Partitioning
Vertical Partitioning
Filegroups
Selecting a Partition Key and Number of Partitions
Partition Function
Partition Scheme
Moving Data between Partitions
Performance Data Collection
Performance Data Collection Explained
Management Data Warehouse
Configuring MDW
Configuring Data Collection
Data Collection Caching
Management Data Warehouse Reports
Resource Governor
Resource Governor Concepts
Resource Pools
Workload Groups
Classification Function
Validate Configuration
Resource Governor Summary
Summary of Exam Objectives
Exam Objectives Fast Track
Exam Objectives Frequently Asked Questions
Self Test
Self Test Quick Answer Key
Chapter 14: MCTS SQL Server 2008 Exam 432 Implementing Objects
Introduction
Understanding DDL and DML Language Elements
Working with Tables and Views
Creating Tables
Creating User-Defined Data Types
Working with Constraints
Creating Indexes
Working with Full-Text Indexes
Viewing and Modifying Data
Creating Views
Creating Stored Procedures
Creating Functions
Creating Triggers
Summary of Exam Objectives
Exam Objectives Fast Track
Exam Objectives Frequently Asked Questions
Self Test
Self Test Quick Answer Key
Index
Appendix: The Real MCTS SQL Server 2008 Exam 432 Self Test
Appendix
Chapter 1: New Features in SQL Server 2008
Chapter 2: Installing SQL Server 2008
Chapter 3: Configuring SQL Server 2008
Chapter 4: Managing Security
Chapter 5: Managing Data Encryption
Chapter 6: Managing High Availability
Chapter 7: Maintaining Your Database
Chapter 8: ETL Techniques
Chapter 9: Managing Replication
Chapter 10: Monitoring and Troubleshooting
Chapter 11: SQL Server XML Support
Chapter 12: Service Broker
Chapter 13: Performance Tuning
Chapter 14: Implementing Objects
Nội dung
612 Chapter14•ImplementingObjects Introduction SQL Server 2008 is a mature enterprise data platform, providing objects for storing, accessing, and modifying data. In this chapter you will discover how to create tables, indexes, stored procedures, functions, and triggers. Designing database objects and writing scripts for their creation is usually the role of database developers. However, database administrators must understand the concepts behind database objects and have the skills necessary to create and modify them. This chapter will provide you with these key skills. Database objects are divided into two broad categories: storage and programma- bility. Tables are units of data storage, structured by columns and rows. Each column in a table stores data of a specific data type. Many built-in data types are available for you to choose from, or you can create custom user-defined data types if necessary. Tables can store large amounts of data, which can take a long time to query. To maximize query performance, you can create fast lookup structures known as indexes. Indexes are created on frequently searched on columns and enable quick traversal when looking for particular values within a table, similar to the index you will find at the end of a printed book. You can associate constraints with table columns. Constraints define the rules to which data in a particular column or columns must adhere. For example, you can use a constraint to specify that values stored in the EMailAddress field are of a particular format. Unique constraints ensure that data for a particular column is unique across the table. For example, you may enforce that product names are always unique in the Products table. Constraints can also define relationships between tables, such as the necessity to have a Customer entity associated with every Order entity. These are known as foreign key constraints. Programmability objects allow you to define Transact-SQL statements that can be reused again and again. Views are based on Transact-SQL SELECT statements. They represent a way of viewing a data set and show data from one or more underlying tables. Views can be updated, allowing you to write data to the view and to update underlying tables. Stored procedures are compiled Transact-SQL statements that perform particular actions. Stored procedures can accept parameters and return values. Functions are similar to stored procedures, except that they always return a value and never update data. Triggers are actions defined on tables that will execute every time data in a table changes. Together these database objects compose a database system. Techniques and best practices for designing a database system are beyond the scope of this book. However you must understand the concepts behind database systems so that you can maintain them correctly and effectively. ImplementingObjects•Chapter14 613 Understanding DDL and DML Language Elements Transact-SQL is the language used to create objects and access data in SQL Server. Data Manipulation Language, (DML) is part of the Transact-SQL language that allows you to insert, modify, and delete data in SQL Server tables. The core state- ments that constitute DML are INSERT, UPDATE, DELETE, and MERGE. In this chapter you will only use these statements in a basic way, as they are outside the scope of this book and exam. Data Definition Language (DDL) is a subset of Transact-SQL that deals with creating database objects such as tables, constraints, and stored procedures. You will examine these statements in depth as they are mapped directly to the exam objectives. SQL Server 2008 Management Studio provides a rich user interface for creating these database objects. However, not all functionality is available within the user interface, and often you will use DDL scripts to create your database objects. The SQL Server 2008 Management Studio user interface simply allows you to create an underlying DDL statement using the appropriate GUI component. Figure 14.1 shows the user interface for creating a table. The DDL statement for creating the same table is shown in Example 14.1. Figure 14.1 SQL Server Management Studio User Interface 614 Chapter14•ImplementingObjects The key DDL statements are CREATE, ALTER, and DROP. The CREATE statement creates a SQL Server database object, like a table, view, or stored procedure. Example 14.1 creates a new table named Produce and a new view named Fruits. In this example we also use the INSERT DML statement to add three rows into our new table. Te s T Da y Ti p Remember that the user interface provided by SQL Server 2008 Management Studio allows you to visually design DDL statements. Any task that is available in SQL Server 2008 Management Studio can be completed using a DDL script, but not all options available within a DDL script are available within the user interface. Example 14.1 Using the CREATE DDL Statement to Create a New Table and View USE AdventureWorks; GO Use the CREATE DDL statement to create a new table named Produce CREATE TABLE Produce (ProductID int PRIMARY KEY, ProductName varchar(50), ProductType varchar(20)) Use the INSERT DML statement to add rows to the Produce table INSERT Produce VALUES (1, 'Tomato', 'Vegetable'), (2, 'Pear', 'Fruit'), (3, 'Kiwifruit', 'Fruit'); GO Use the CREATE DDL statement to create a new view named Fruit that shows us only produce of type 'Fruit' CREATE VIEW Fruit AS SELECT * FROM Produce WHERE ProductType = 'Fruit'; GO ImplementingObjects•Chapter14 615 The ALTER DDL statement changes an existing object and it can be used to add or remove columns from a table. You can also use this statement to change the definition of a view, stored procedure, trigger, or function. Example 14.2 adds a Price column to the Produce table we have created in Example 14.1. In this example we also redefine the view to include the new Price column. Do not confuse the ALTER statement, which changes an object definition, with the UPDATE statement, which changes data in a table. Use the SELECT statement to view the data in the Fruit View SELECT * FROM Fruit Results: ProductID ProductName ProductType 2 Pear Fruit 3 Kiwifruit Fruit Example 14.2 Using the ALTER DDL Statement to Add a New Column to a Table and Redefine a View Add a new column ALTER TABLE Produce ADD Price Money; GO Use the UPDATE statement to set prices UPDATE Produce SET Price = 2.50 WHERE ProductID = 1; UPDATE Produce SET Price = 3.95 WHERE ProductID = 2; UPDATE Produce SET Price = 4.25 WHERE ProductID = 3; GO Redefine the view ALTER VIEW Fruit AS SELECT ProductID, ProductName, Price FROM Produce WHERE ProductType = 'Fruit'; GO SELECT * FROM Fruit Results: 616 Chapter14•ImplementingObjects The DROP DDL statement removes an object from the database. If other objects depend on the object you are attempting to drop, this statement will not succeed and an error will be raised. Example 14.3 deletes data from the Produce table, and then removes both the Fruit view and the Produce table from the database. In this example, we also attempt to drop the Person.Contact table. This operation will fail, as other objects depend on Person.Contact. Do not confuse the DROP statement, which removes an object from the database, with the DELETE statement, which deletes data from a table. ProductID ProductName Price 2 Pear 3.95 3 Kiwifruit 4.25 Example 14.3 Using the DROP DDL Statement to Remove Tables and Views from a Database DELETE FROM Produce; SELECT * FROM Fruit; Results: ProductID ProductName Price (0 row(s) affected) DROP VIEW Fruit; GO DROP TABLE Produce; GO DROP TABLE Person.Contact; Results: Msg 3726, Level 16, State 1, Line 1 Could not drop object 'Person.Contact' because it is referenced by a FOREIGN KEY constraint. . procedures. You will examine these statements in depth as they are mapped directly to the exam objectives. SQL Server 2008 Management Studio provides a rich user interface for creating these database. using the appropriate GUI component. Figure 14.1 shows the user interface for creating a table. The DDL statement for creating the same table is shown in Example 14.1. Figure 14.1 SQL Server. function. Example 14.2 adds a Price column to the Produce table we have created in Example 14.1. In this example we also redefine the view to include the new Price column. Do not confuse the ALTER