Tải bản đầy đủ (.pdf) (5 trang)

Brad’s Sure Guide to SQL Server Maintenance Plans- P13 ppt

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (527.38 KB, 5 trang )

Chapter 3: Getting Started with the Maintenance Plan Wizard
61
Figure 3.8: The Define Database Check Integrity task configuration screen.
The basic layout of this screen is more or less the same for every task.
• Database Selection – a drop-down box to choose the database(s) on which the task will
execute. This step is common to most tasks.
• Task-specific configuration options – a set of configuration options specific to a
given task.
• Task Scheduling – an option to schedule the task. This step is common to every
task, assuming that you chose Separate schedules for each task when you first
started the Wizard.
Although this screen looks simple, it is hiding a lot of detail. Let's take a look at each of the
three sections, although we'll save a lot of these details for later chapters.
Chapter 3: Getting Started with the Maintenance Plan Wizard
62
Database Selection
As you might expect, the first step when configuring most tasks is to specify the database or
databases on which the maintenance task to act. The Databases drop-down box appears on
the configuration screen for all tasks that can be configured through the Wizard, with the
exception of the Execute SQL Server Agent Job (Chapter 10), History CleanUp (Chapter
11) and Maintenance Cleanup (Chapter 15) tasks, where database selection is not necessary.
In other cases, the database selection process for a task (for example the Rebuild Index task,
see Chapter 7) is slightly more complex, as you will be offered the chance to narrow the scope
of the task to specific objects within a selected database. However, most often you will want a
task to act on the database as a whole.
For all tasks where database selection is relevant, most of the other options on the screen will
be grayed out until you select at least one database.
Figure 3.9: The database selection drop-down box.
So let's take a close look at how you use this option, as a lot of it is hidden away from us at the
moment. To select which databases you want to run this task against, click on the <Select one
or more> drop-down box, and the screen shown in Figure 3.10 appears. This screen allows us


to make one selection from four different choices.
All databases
This option means exactly what it says. If you select this option, every database on your SQL
Server instance will have the task run against it. One advantage of using this option is that
it covers both user and system databases and, if you add any databases at any time, even
after the Maintenance Plan has been created and is in production, they will automatically be
included when this task runs. As such, this option allows you to create a single Maintenance
Plan to cover all of your databases.
On the other hand, if you include all your databases in a single Maintenance Plan, you have
less flexibility. This means that, although selecting this option may seem to be the best choice,
it may not actually be the best, because you may need to treat some databases differently from
others. We will be talking more about this later in the book.
Chapter 3: Getting Started with the Maintenance Plan Wizard
63
Figure 3.10: The Maintenance Plan Wizard needs to know which databases you want to
run the task against.
System databases
This option specifies that your task will only run against the SQL Server instance's system
databases, which include master, model, and msdb (but not tempdb).
This option is commonly used to create a specific Maintenance Plan for your system
databases. Generally, the maintenance tasks you want to perform on system databases are
a little different than those you run against production user databases. For example, system
databases use the Simple Recovery model, and so transaction log backups can't be carried
Chapter 3: Getting Started with the Maintenance Plan Wizard
64
out. On the other hand, most production databases use the Full Recovery model, which
allows transaction log backups to be made. This and other differences between system and
production database maintenance, mean it is common to create separate Maintenance Plans
for each class of databases.
tempdb and Maintenance Plans

tempdb is not included in a Maintenance Plan because it is automatically deleted and
recreated every time SQL Server is restarted.
All user databases
Just as a DBA often wants to create a Maintenance Plan that is specific to system databases,
so he or she will often create a plan dedicated to the maintenance of all production user
databases. A nice feature of this option is that it will automatically include all user databases,
even ones that you create after the Maintenance Plan is created. This is handy because you
don't have to worry about modifying the Maintenance Plan if you subsequently add or delete
databases from your SQL Server. This is the option that we'll use for most of the examples in
this book, as shown in Figure 3.10.
These databases
This final option allows you to build a custom list of databases, both user and system, to
which your task will apply. This option is often used when you want to treat a particular
database differently from the rest of the databases. For example, you may have a policy that,
for databases under a given size, the Rebuild Index task is used, but that the Reorganize
Index and the Update Statistics tasks are preferred on any databases above that size. This
distinction is sometimes made if the Rebuild Index task on a large database takes longer to
execute than the available maintenance window, which could end up blocking users trying
to access the database. As we will learn later in this book, the Reorganize Index and the
Update Statistics tasks, combined, perform a similar function to the Rebuild Index task,
but do so without blocking users.
A disadvantage of this option is that the databases you select here aren't dynamic. By this, I
mean that databases that are created or deleted subsequent to the creation of the plan are
not automatically added to, or removed from, that plan. In the latter case, this will mean
that an error will occur when the Maintenance Plan is run. You have to manually edit the
Maintenance Plan every time you want to add or delete a database to be used by the plan.
Chapter 3: Getting Started with the Maintenance Plan Wizard
65
Ignore databases where the state is not online
Finally, on this screen is an Ignore databases where the state is not online checkbox which,

by default, is activated. This means that any databases that are oine at the time when the
plan is running will be ignored. If you uncheck this box, and a maintenance task attempts
to run against an oine database, then the Maintenance Plan will fail when it is executed
because it will not be able to complete its operation.
Generally speaking, I suggest you leave this option activated to ensure that the plan works
successfully on all online databases.
Ignore databases where the state is not online…
…is only available in SQL Server 2008. If you run a SQL Server 2005 Maintenance Plan,
and it includes tasks to be run against an oine database, then the Maintenance Plan
will fail.
Task-Specific Configuration Options
Click on OK to be returned to the Define Database Check Integrity Task screen, with the
database choice displayed in the drop-down box, as shown in Figure 3.11.

×