chapter 2 administrating db engine. database engine the database engine is the core service for...

46
Chapter 2 Administrating DB Engine

Upload: mae-kelley

Post on 24-Dec-2015

248 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Chapter 2 Administrating DB Engine. Database Engine  The Database Engine is the core service for storing, processing, and securing data.  It provides

Chapter 2

Administrating DB Engine

Page 2: Chapter 2 Administrating DB Engine. Database Engine  The Database Engine is the core service for storing, processing, and securing data.  It provides

Database Engine The Database Engine is the core service for storing,

processing, and securing data. It provides controlled access and rapid transaction

processing to meet the requirements of the most demanding data consuming applications.

Use the Database Engine to create relational DBs for online transaction processing (OLTP) or online analytical processing data (OLAP). This includes creating tables and DB objects such as indexes, views, and stored procedures.

You can use SQL Server Management Studio to manage the database objects, and SQL Server Profiler for capturing server events.

Page 3: Chapter 2 Administrating DB Engine. Database Engine  The Database Engine is the core service for storing, processing, and securing data.  It provides

Server Management Studio SQL Server Management Studio is an

integrated environment for accessing, configuring, managing, administering, and developing all components of SQL Server.

It combines a broad group of graphical tools with a number of rich script editors to provide access to SQL Server to developers and administrators.

Page 4: Chapter 2 Administrating DB Engine. Database Engine  The Database Engine is the core service for storing, processing, and securing data.  It provides

Server Management Studio (2)

Show how to start Server Management Studio

Show how to create a DB Show how to create a table

Page 5: Chapter 2 Administrating DB Engine. Database Engine  The Database Engine is the core service for storing, processing, and securing data.  It provides

Manage Server

Page 6: Chapter 2 Administrating DB Engine. Database Engine  The Database Engine is the core service for storing, processing, and securing data.  It provides

General

Page 7: Chapter 2 Administrating DB Engine. Database Engine  The Database Engine is the core service for storing, processing, and securing data.  It provides

Memory

Page 8: Chapter 2 Administrating DB Engine. Database Engine  The Database Engine is the core service for storing, processing, and securing data.  It provides

Processors

Page 9: Chapter 2 Administrating DB Engine. Database Engine  The Database Engine is the core service for storing, processing, and securing data.  It provides

Security

Page 10: Chapter 2 Administrating DB Engine. Database Engine  The Database Engine is the core service for storing, processing, and securing data.  It provides

Connections

Page 11: Chapter 2 Administrating DB Engine. Database Engine  The Database Engine is the core service for storing, processing, and securing data.  It provides

DB Setting

Page 12: Chapter 2 Administrating DB Engine. Database Engine  The Database Engine is the core service for storing, processing, and securing data.  It provides

Advanced

Page 13: Chapter 2 Administrating DB Engine. Database Engine  The Database Engine is the core service for storing, processing, and securing data.  It provides

Permissions – More on Chapter 9

Page 14: Chapter 2 Administrating DB Engine. Database Engine  The Database Engine is the core service for storing, processing, and securing data.  It provides

Getting All Settings

Select * from sys.configurations

Page 15: Chapter 2 Administrating DB Engine. Database Engine  The Database Engine is the core service for storing, processing, and securing data.  It provides

DB Engine Folders

Databases Security Server Objects Replications (Chapter 15) Management

Page 16: Chapter 2 Administrating DB Engine. Database Engine  The Database Engine is the core service for storing, processing, and securing data.  It provides

The Database Folder

System Databases• master – all sys info, guard this• model – specifies what a newly created db• msdb – used by SQL Server Agent• tempdb – store temp info cleared when start

Database Snapshots• Read-only databases – more in Chapter 7

User DBs

Page 17: Chapter 2 Administrating DB Engine. Database Engine  The Database Engine is the core service for storing, processing, and securing data.  It provides

Security Folder

Logins Server Roles Credentials (More next) Cryptographic Providers (Chapter 11) Audits (Chapter 17) Server Audit Specifications (Chapter 17)

Page 18: Chapter 2 Administrating DB Engine. Database Engine  The Database Engine is the core service for storing, processing, and securing data.  It provides

Security Folder—Credentials A credential is a record that contains the authentication

information, mostly Windows user name and password, required to connect to a resource outside of SQL Server.

When the external resource is Windows, the user is authenticated as the Windows user specified in the credential. A single credential can be mapped to multiple SQL Server logins. However, a SQL Server login can be mapped to only one credential.

Page 19: Chapter 2 Administrating DB Engine. Database Engine  The Database Engine is the core service for storing, processing, and securing data.  It provides

Server Objects Backup Devices Endpoints (Chapter 13)

• Is used to manage security • Example of endpoints are DB mirroring, service broker,

SOAP, etc

Linked Servers• Used to access databases on a different server or

instance

Triggers• A list of all triggers – a table or view level object

Page 20: Chapter 2 Administrating DB Engine. Database Engine  The Database Engine is the core service for storing, processing, and securing data.  It provides

Replications Replication is a set of technologies for

copying and distributing data and database objects from one database to another and then synchronizing between databases to maintain consistency.

Using replication, you can distribute data to different locations and to remote or mobile users as long as they are connected.

More later

Page 21: Chapter 2 Administrating DB Engine. Database Engine  The Database Engine is the core service for storing, processing, and securing data.  It provides

Management Folder Policy Management (Chapter 10) Data Collections (Chapter 17) Resource Governor (Chapter 16) Maintenance Plans (Chapter 6) SQL Server Logs

• Can have up to 99 archived logs

Database Mail Distributed Transaction Coordinator Legacy

Page 22: Chapter 2 Administrating DB Engine. Database Engine  The Database Engine is the core service for storing, processing, and securing data.  It provides

Administrating DB Properties Selections are

• General• Files• Filegroups• Options• Change Tracking• Permissions• Extended

Properties• Mirroring• Transaction Log

Shipping

Page 23: Chapter 2 Administrating DB Engine. Database Engine  The Database Engine is the core service for storing, processing, and securing data.  It provides

Files You will always have at least two files:

• One for data – can have many The first one has the extension .mdf, then .ndf

• One for log – can have many All have the extension .ldf

Page 24: Chapter 2 Administrating DB Engine. Database Engine  The Database Engine is the core service for storing, processing, and securing data.  It provides

Files Use Filegroups to manage data storage (more

later) Should use RAID 10 for both according to book Should use RAID 1 for log, RAID 5 or 10 for data

(Jie) Autogrowth – easy to manage, may cause

performance issues FILESTREAM data – files can be access by both

DBMS and the file system (more later)

Page 25: Chapter 2 Administrating DB Engine. Database Engine  The Database Engine is the core service for storing, processing, and securing data.  It provides

DISK

See DISK PPS

Page 26: Chapter 2 Administrating DB Engine. Database Engine  The Database Engine is the core service for storing, processing, and securing data.  It provides

Filegroups

Page 27: Chapter 2 Administrating DB Engine. Database Engine  The Database Engine is the core service for storing, processing, and securing data.  It provides

More on Filegroups A filegroup is a logical structure that lets DBAs group data

files and manage them as a logical unit The Advantages of filegroups

• A filegroup is a logical grouping of data files• Let’s you place database objects into a specific group of data files• Allows you to backup only one filegroup at a time

Useful for backing up VLDBs

• Can be marked as read-only or write only Speeds up access to archive data

The Disadvantages of filegroups• More work • May not improve performance if you already using RAID 5

Page 28: Chapter 2 Administrating DB Engine. Database Engine  The Database Engine is the core service for storing, processing, and securing data.  It provides

Even More On Filegroup There are two types of filegroups: primary and

user-defined. Each database can have a maximum of 32766

filegroups. SQL Server 2008 always contains at least one filegroup, the primary file group.

Only one filegroups is the default. A filegroup can consist of multiple data files

spread across multiple drives. Transaction log files cannot be part of a filegroup.

Page 29: Chapter 2 Administrating DB Engine. Database Engine  The Database Engine is the core service for storing, processing, and securing data.  It provides

One More The primary filegroup contains the primary data file

including system tables. When you create secondary data files within a database, they are placed in the default filegroup, unless told differently.

When you create database objects (such as tables and indexes) and add data to these objects, SQL Server 2008 uses the space within each of the data files within the filegroup proportionally, rather than allocating space from and writing data to one data file until it is full before writing to the next data file.

Page 30: Chapter 2 Administrating DB Engine. Database Engine  The Database Engine is the core service for storing, processing, and securing data.  It provides

File Groups

This proportional fill method allows a database to be created that spans across multiple disks, with associated performance benefits.

For example, if your SQL Server 2005 system has four disks, you could use one disk for the transaction log and the remaining three disks for the data files (one per disk).

Page 31: Chapter 2 Administrating DB Engine. Database Engine  The Database Engine is the core service for storing, processing, and securing data.  It provides

File Groups

Rather than placing all secondary data files in a single filegroup, you can create user-defined filegroups to host secondary data files.

On a system with multiple filegroups, you can specify the filegroup into which a newly created database object will be placed. This can have performance benefits, but also requires more administrative overhead and performance tuning expertise.

At creation, a database object is placed in the default filegroup if no filegroup is specified. The default filegroup is the primary filegroup until the default is changed using the ALTER DATABASE Transact-SQL

statement.

Page 32: Chapter 2 Administrating DB Engine. Database Engine  The Database Engine is the core service for storing, processing, and securing data.  It provides

Filegroup Considerations

The first (or primary) data file must reside on the primary filegroup.

All system files must be placed on the primary filegroup. A file cannot be a member of more than one filegroup at

a time. Filegroups can be allocated indexes, tables, text, ntext,

and image data. New data pages are not automatically allocated to user-

defined filegroups if the primary filegroup runs out of space.

If you place tables in one filegroup and their corresponding indexes in a different filegroup, the two file groups must be backed up as a single unit—they cannot be backed up separately.

© Wiley Inc. 2006. All Rights Reserved.

Page 33: Chapter 2 Administrating DB Engine. Database Engine  The Database Engine is the core service for storing, processing, and securing data.  It provides

DB-Options There are a large

number of them, we will just pick a few • Collation• Recovery model

Full Simple Bulk-Logged

• Compatibility level• Many options

Page 34: Chapter 2 Administrating DB Engine. Database Engine  The Database Engine is the core service for storing, processing, and securing data.  It provides

Recovery ModelRecovery model Description

Work loss exposure

Recover to point in time?

Simple •No log backups•Automatically reclaims log space •eliminating the need to manage the transaction log space.

Since the last backup

Last backup

Full •Requires log backups.•No work is lost due to a lost or damaged data file.•Can recover to an arbitrary point in time (for example, prior to application or user error).

Normally none.If the tail of the log is damaged, changes since the most recent log backup must be redone.

Can recover to a specific point in time, assuming that your backups are complete up to that point in time

Bulk logged

•Requires log backups.•permits high-performance bulk copy operations.•Reduces log space usage by bulk logging most bulk operations.

Any backup Can recover to the end of any backup. Point-in-time recovery is not supported.

Page 35: Chapter 2 Administrating DB Engine. Database Engine  The Database Engine is the core service for storing, processing, and securing data.  It provides

Change Tracking

New feature

Page 36: Chapter 2 Administrating DB Engine. Database Engine  The Database Engine is the core service for storing, processing, and securing data.  It provides

Permissions

Second look

Page 37: Chapter 2 Administrating DB Engine. Database Engine  The Database Engine is the core service for storing, processing, and securing data.  It provides

Properties Extended Permissions

User defined properties and values for database objects. – Skip

Page 38: Chapter 2 Administrating DB Engine. Database Engine  The Database Engine is the core service for storing, processing, and securing data.  It provides

Mirroring

Create a duplicate copy• Support fault

tolerance and auto failover

More on Chapter 13

Page 39: Chapter 2 Administrating DB Engine. Database Engine  The Database Engine is the core service for storing, processing, and securing data.  It provides

Transaction Log Shipping

A way of replication and fault tolerence

Does not support auto failover

Page 40: Chapter 2 Administrating DB Engine. Database Engine  The Database Engine is the core service for storing, processing, and securing data.  It provides

More and more

A few more items• Reports• Detaching and attaching databases• Scripting a DB or a DB object• Backing up and restore • Import/Export database• Taking a DB offline• Shrinking a DB• Compress data – do not do it unless is it absolutely necessary• Horizontally partitioning of tables and indexes • Enable FILESTREAM data• Yes, you can rename a database

Page 41: Chapter 2 Administrating DB Engine. Database Engine  The Database Engine is the core service for storing, processing, and securing data.  It provides

Standard reports - Instance

Page 42: Chapter 2 Administrating DB Engine. Database Engine  The Database Engine is the core service for storing, processing, and securing data.  It provides

Standard reports -- database

Page 43: Chapter 2 Administrating DB Engine. Database Engine  The Database Engine is the core service for storing, processing, and securing data.  It provides

Detach

For the purpose of parking the database

Page 44: Chapter 2 Administrating DB Engine. Database Engine  The Database Engine is the core service for storing, processing, and securing data.  It provides

Attach a DB

Database Attach • Then select the

mdf file of the database

Another way of moving/copying a database

Page 45: Chapter 2 Administrating DB Engine. Database Engine  The Database Engine is the core service for storing, processing, and securing data.  It provides

SQL Agent

Make sure it is start – it does not auto start when needed• Jobs – an job for a scheduled run• Alerts – sending alert messages more in

chapter 17• Proxies – manage of credentials• Error Logs

Page 46: Chapter 2 Administrating DB Engine. Database Engine  The Database Engine is the core service for storing, processing, and securing data.  It provides

Operator

A person