You are on page 1of 31

MCTS Daniel Ramos - danielramos@sistemasuni.edu.

pe

MCTS Daniel Ramos - danielramos@sistemasuni.edu.pe

MCTS Daniel Ramos - danielramos@sistemasuni.edu.pe

File Type

Extension

Description The primary data file contains the startup information for the database and pointers to other files Secondary files can be used to spread user data across multiple disks by putting each file on a different disk drive Log files hold all the information that is used to recover the database

Primary Files

.mdf

Secondary Files

.ndf

Transaction logs

.ldf

MCTS Daniel Ramos - danielramos@sistemasuni.edu.pe

Data file: .mdf or .ndf

Log file: .ldf

Extent: 8 contiguous 8KB pages

Page: 8KB

MCTS Daniel Ramos - danielramos@sistemasuni.edu.pe

Data modification is sent by application

Buffer Cache

Modification is recorded in transaction log on disk

Data pages are located in, or read into, the buffer cache and then modified

Checkpoint writes committed transactions to database

MCTS Daniel Ramos - danielramos@sistemasuni.edu.pe

File Type Primary and secondary files tempdb Transaction Logs

Consideration
If you have tables that are frequently used together, you

should put them on separate filegroups and physical drives


Place the tempdb database on a fast disk drive

subsystem to ensure good performance


Create the transaction log on a physically separate disk

or RAID array

Disk Planning and File Placement


The most important considerations are the number of disks or spindles available to a particular drive and the speed of the drives involved

MCTS Daniel Ramos - danielramos@sistemasuni.edu.pe

AdventureWorks Database
sys... sys.filegroups sys.objects sys.indexes

... Sales.SalesOrder
Sales.Customer Production.Product Ord.HistYear2

Ord.HistYear1

C:\
AdventureWorks_ Data.mdf

D:\
OrdHist1.ndf OrdHist2.ndf

E:\
AdventureWorks_ Log.ldf

Primary Filegroup

OrderHistoryGroup

MCTS Daniel Ramos - danielramos@sistemasuni.edu.pe

Filegroups can be created when the database is first created or later when more files are added to the database

Files cannot be moved to different filegroups A file cannot be a member of more than one filegroup
Filegroups can contain only data files

Create filegroups on different local physical disks


Put tables in the same join queries in different filegroups Put heavily accessed tables on different filegroups

MCTS Daniel Ramos - danielramos@sistemasuni.edu.pe

Partition Function Range

Partitioning Scheme

January Orders

File1

February

File2

March
MCTS Daniel Ramos - danielramos@sistemasuni.edu.pe

File3

MCTS Daniel Ramos - danielramos@sistemasuni.edu.pe

MCTS Daniel Ramos - danielramos@sistemasuni.edu.pe

MCTS Daniel Ramos - danielramos@sistemasuni.edu.pe

model database

Primary

Secondary

Log

MCTS Daniel Ramos - danielramos@sistemasuni.edu.pe

Using Transact-SQL to create a database


CREATE DATABASE database_name [ ON [ PRIMARY ] [ filespec [, n] ] [ FILEGROUP filegroup_name [DEFAULT] filespec [, n] ] [, n] ] [ LOG ON [filespec [, n] ] [ COLLATE collation_name ] ]

database_name ON PRIMARY

LOG ON
FILEGROUP filegroup_name COLLATE
MCTS Daniel Ramos - danielramos@sistemasuni.edu.pe

Database-level options are unique to each database

Here are some important database options:


Option AUTO_CLOSE AUTO_SHRINK Description The database is closed and shut down cleanly when the last user of the database exits. When set to ON, the database files are candidates for periodic shrinking. When READ_ONLY is specified, users can retrieve data, but cannot modify the data. Database and transaction log backups are used to provide full recoverability from media failure.

READ_ONLY
RECOVERY SIMPLE

MCTS Daniel Ramos - danielramos@sistemasuni.edu.pe

Databases expand according to growth parameters

Manually expand a database by allocating additional space Use the MAXSIZE parameter to specify maximum size
The log transaction file can be truncated

If a database exhausts the space, Error 1105 is raised

MCTS Daniel Ramos - danielramos@sistemasuni.edu.pe

Each file within a database can be reduced Both data and transaction log files can be shrunk Files are always shrunk from the end

MCTS Daniel Ramos - danielramos@sistemasuni.edu.pe

Namespaces for database objects


Person

Contact
(Server1.AdventureWorks2008.Person.Contact)

Sales
Customer
(Server1.AdventureWorks2008.Sales.Customer)

dbo ErrorLog
(Server1.AdventureWorks2008.dbo.ErrorLog)

AdventureWorks2008

MCTS Daniel Ramos - danielramos@sistemasuni.edu.pe

What is the Syntax for Creating Schemas?


CREATE SCHEMA schema_name | AUTHORIZATION owner_name [ table_definition | view_definition | grant_statement | revoke_statement | deny_statement ]

Creating Schemas using SQL Server Management Studio

MCTS Daniel Ramos - danielramos@sistemasuni.edu.pe

MCTS Daniel Ramos - danielramos@sistemasuni.edu.pe

MCTS Daniel Ramos - danielramos@sistemasuni.edu.pe

Configuration servers store a list of SQL Server instances

List is organized into configuration server groups Actions taken will act on all servers in the server group

MCTS Daniel Ramos - danielramos@sistemasuni.edu.pe

Policy framework helps to:


Scale with Ease

Scales across multiple servers Helps enforce consistent policies across enterprise
Conform to Desired Intent

Offers a logical view of the system configuration Defines the configuration of data services
Monitor Performance

Manage the operation of multiple servers Optimize the execution of your data services

MCTS Daniel Ramos - danielramos@sistemasuni.edu.pe

Policy-Based Management allows you to define what can or cannot be done on the server

Components of Policy-Based Management:


Targets

Entities that are managed by Policy-Based Management


Policies

A condition and the expected behavior


Conditions

A Boolean expression that specifies a set of allowed states


Facets

A set of properties that model behavior or characteristics


MCTS Daniel Ramos - danielramos@sistemasuni.edu.pe

Policies are created and managed with Management Studio The process includes the following steps:

1 2

Select a Management facet that contains the properties

Define a condition that specifies the management facet Define a policy that contains the filters for the target sets Check if SQL Server is in compliance with the policy

3 4

MCTS Daniel Ramos - danielramos@sistemasuni.edu.pe

MCTS Daniel Ramos - danielramos@sistemasuni.edu.pe

MCTS Daniel Ramos - danielramos@sistemasuni.edu.pe

MCTS Daniel Ramos - danielramos@sistemasuni.edu.pe

MCTS Daniel Ramos - danielramos@sistemasuni.edu.pe

Daniel Ramos Castaeda


danielramoscastaneda@hotmail.com

MCTS Daniel Ramos - danielramos@sistemasuni.edu.pe

You might also like