35

Denny Cherry [email protected] @mrdenny

Embed Size (px)

Citation preview

Page 1: Denny Cherry mrdenny@dcac.co  @mrdenny
Page 2: Denny Cherry mrdenny@dcac.co  @mrdenny

Introduction to SQL Server Management for the Non-DBA

Denny [email protected]/mrdenny

DBI-B220

Page 4: Denny Cherry mrdenny@dcac.co  @mrdenny

Files, File Groups, DisksBackupsRecovery ModelDatabase MaintenanceCompressionCorruptionCompatibility LevelIndexes

Agenda

Page 5: Denny Cherry mrdenny@dcac.co  @mrdenny

Each database is made up of at least two filesOne file is dataOne file is transaction log

Files, File Groups, Disks

http://www.flickr.com/photos/photomequickbooth/4011249096/

Page 6: Denny Cherry mrdenny@dcac.co  @mrdenny

File Groups are made up of filesFiles hold the dataDisks Hold Files

Files, File Groups, Disks

http://www.flickr.com/photos/photomequickbooth/4011249096/

Page 7: Denny Cherry mrdenny@dcac.co  @mrdenny

Tables created within file groupsAllows tables to be spread across disksFile groups typically only need one 1 file

Files, File Groups, Disks

https://www.flickr.com/photos/andrewnebbett/5356889496/

Page 8: Denny Cherry mrdenny@dcac.co  @mrdenny

Single file group4-8 files for most instancesMore if using lots of temporary tables, pivoting

TempDB Database

https://www.flickr.com/photos/rachaelvoorhees/4988206451/

Page 9: Denny Cherry mrdenny@dcac.co  @mrdenny

Three Recovery Models AvailableSimpleBulk-LoggedFull

Used to control amount of loggingControls recoverability

Recovery Models

http://www.flickr.com/photos/decade_null/142235888/

Page 10: Denny Cherry mrdenny@dcac.co  @mrdenny

Minimal LoggingNo Point In Time RecoveryDoes Not Disable Logging

Simple Recovery Model

http://www.flickr.com/photos/noii/1337970464/

Page 11: Denny Cherry mrdenny@dcac.co  @mrdenny

Some commands are bulk loggedMost commands are fully loggedPoint In Time Recovery Supported

Bulk Logged Recovery Model

http://www.flickr.com/photos/4nitsirk/3778043845/

Page 12: Denny Cherry mrdenny@dcac.co  @mrdenny

Almost nothing is bulk loggedPoint in time recovery is supportedFull Data Protection

Full Recovery

http://www.flickr.com/photos/dok1/5623000758/

Page 13: Denny Cherry mrdenny@dcac.co  @mrdenny

3 Different Kinds of BackupsFull BackupsDifferential BackupsTransaction Log Backups

Advanced Backup OptionsFile Group Backups

Backups Saved On Another Machine

Backups

http://www.flickr.com/photos/gemstone/406866312/

Page 14: Denny Cherry mrdenny@dcac.co  @mrdenny

Makes a point in time copy of the databaseDatabase is in the state the database was at the end of the backupShould be done daily or weekly

Full Backups

Page 15: Denny Cherry mrdenny@dcac.co  @mrdenny

Backs up changes since last full backupUsually used for reporting databasesOptional database backup type

Differential Backups

Page 16: Denny Cherry mrdenny@dcac.co  @mrdenny

Backs up transactions since last log backupFrequency should be dictated by business need (RPO)Required for full or bulk logged recovery model

Transaction Log Backups

Page 17: Denny Cherry mrdenny@dcac.co  @mrdenny

Full RestoreDifferential RestoreTransaction Log RestorePage Level RestoreFile Group Restore

Restoring Data

http://www.flickr.com/photos/fun_flying/2959307155/

Page 18: Denny Cherry mrdenny@dcac.co  @mrdenny

Databases need TLCIndex RebuildingIndex DefragmentingUpdate Statistics

Database Maintenance

http://www.flickr.com/photos/wjlonien/6309343565/

Page 19: Denny Cherry mrdenny@dcac.co  @mrdenny

Database MaintenanceIndex Rebuild

Can be online or offline depending on version, edition and column data typesCreates new indexes then drops old indexUpdates Statistics on index

Index Defrag

Always OnlineMoves data around pages row by rowOnly moves rows that need to be moved

http://www.flickr.com/photos/usnavy/5488581781/

Page 20: Denny Cherry mrdenny@dcac.co  @mrdenny

How SQL Server figures out how to access dataStatistics are used to create an execution planStatistics are a sampling of the values within a table or indexStatistics contain up to 200 samples of the values within the tableStatistics track the number of values between sampled values

Statistics?

http://www.flickr.com/photos/franganillo/3676227162/

Page 21: Denny Cherry mrdenny@dcac.co  @mrdenny

Statistics?

Page 22: Denny Cherry mrdenny@dcac.co  @mrdenny

Compression

https://www.flickr.com/photos/smithser/6122836965/

• Saves space within:• The database• Memory• Backups

• Costs CPU speed, but usually worth it• Data Compression is Page or Row• Backup Compression is an on or off

Page 23: Denny Cherry mrdenny@dcac.co  @mrdenny

All databases can become corruptCorruption is usually a hardware problemCorruption should be checked for regularlyDepending on what is corrupt it may be repaired without data lossCorruption is checked for and repaired using DBCC CHECKDBCorruption will happen, how you prepare for it will determine how easily you can survive itSome corruption can’t be repaired and must be restored from a backup

Corruption

Page 24: Denny Cherry mrdenny@dcac.co  @mrdenny

Compatibility levels tell SQL Server which language syntax to supportDoes not effect the version of the SQL Server the database can be restored toSQL Supports several down level compatibility levels.

SQL 2012 supports SQL 2005 and upSQL 2008 R2 and below support SQL 6.5 and up

Compatibility Level

Page 25: Denny Cherry mrdenny@dcac.co  @mrdenny

Used to speed up queriesSorted based on the columns within the indexCauses duplicate data to be storedTrades space for speedIndexes are ½ art and ½ science

Indexes

http://www.flickr.com/photos/annarbor/4350627292/

Page 26: Denny Cherry mrdenny@dcac.co  @mrdenny

ClusteredNonclusteredFull TextSpatialColumnStoreXMLSemantic Search

Indexes

http://www.flickr.com/photos/tryingyouth/2456237/

Page 27: Denny Cherry mrdenny@dcac.co  @mrdenny

Indexes

Page 28: Denny Cherry mrdenny@dcac.co  @mrdenny

Indexes

Page 29: Denny Cherry mrdenny@dcac.co  @mrdenny

Indexes aren’t freeEvery index added slows down INSERT/UPDATE/DELETE operationsOnly create indexes where the cost of having the index is worth itUnused indexes can be removed from the database

Indexes

Page 30: Denny Cherry mrdenny@dcac.co  @mrdenny

http://dcac.co/res/teched2014

Additional Reading…

Page 31: Denny Cherry mrdenny@dcac.co  @mrdenny

27 Hands on Labs + 8 Instructor Led Labs in Hall 7

DBI Track resources

Free SQL Server 2014 Technical Overview e-book

microsoft.com/sqlserver and Amazon Kindle StoreFree online training at Microsoft Virtual Academy

microsoftvirtualacademy.com Try new Azure data services previews!Azure Machine Learning, DocumentDB, and Stream Analytics

Page 32: Denny Cherry mrdenny@dcac.co  @mrdenny

Resources

Learning

Microsoft Certification & Training Resources

www.microsoft.com/learning

Developer Network

http://developer.microsoft.com

TechNet

Resources for IT Professionals

http://microsoft.com/technet

Sessions on Demand

http://channel9.msdn.com/Events/TechEd

Page 33: Denny Cherry mrdenny@dcac.co  @mrdenny

Please Complete An Evaluation FormYour input is important!TechEd Schedule Builder CommNet station or PC

TechEd Mobile appPhone or Tablet

QR code

Page 34: Denny Cherry mrdenny@dcac.co  @mrdenny

Evaluate this session

Page 35: Denny Cherry mrdenny@dcac.co  @mrdenny

© 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.