SQL Server 2012: Common Tasks and Solutions For Non-SQL Administrators
SQL Server 2012: Common Tasks and Solutions For Non-SQL Administrators
Microsoft Confidential 3
Module 5: Managing SQL
Server Databases
Module Overview
Microsoft Confidential 4
Module 5: Managing SQL
Server Databases
Microsoft Confidential 5
What is a Database?
• A collection of objects.
Server 1
INST1 Master INST2
AdventureWorks2012
Model
Stored
Tables Views
Procedures
MSDB
Functions
TempDB
Microsoft Confidential 6
System Databases
MSDB ––Used
Model
Resource
TempDB
Master by information.
Template.
–System SQL
– Temporary
Hidden Server
database. Agent.
user objects.
Master
INST1
Model
Server 1 Resource
MSDB
TempDB
Microsoft Confidential 7
Is it supported to directly update system objects?
Microsoft Confidential 8
Demonstration: Viewing
System Databases
User Databases
INST1
AdventureWorks2012
Person.Address
Server 1
Microsoft Confidential 10
Demonstration : Create a
User Database
Lab: Create a User Database
Lesson Knowledge Check
Microsoft Confidential
Module 5: Managing SQL
Server Databases
Microsoft Confidential 15
Database Files Logical_file_name – mydb.
OS_file_name
-E:\MSSQL11….\DATA
\MyDB.mdf
Stores the data.
Asynchronous,
Random, Database Files
Read, Write Stores changes to
the data.
Synchronous,
Sequential, Write.
Stores data and info Data Log Extention- .ldf
about other files.
Extention - .mdf
Stores data.
Primary Secondary Extention - .ndf
Microsoft Confidential 16
Database Filegroups
Data Log
Microsoft Confidential 17
Demonstration: Add a file
and a filegroup to a database
Lab: Add files and filegroup
Lesson Knowledge Check
Can you create more than one transaction log file for a database?
Microsoft Confidential
Module 5: Managing SQL
Server Databases
Microsoft Confidential 22
Auto Growth
•Controls how the file grows
Manage
Proactively
AutoGrowth
Exponential Constant
growth.
File Growth growth.
Not recommended. Recommended!
Percent Megabytes
Microsoft Confidential
Auto Shrink
• Automatically reduces the size and compacts the data and log files.
AutoShrink
Microsoft Confidential
What are the performance implications of auto growth
and auto shrink options?
Microsoft Confidential
Best Practices for auto growth and auto shrink
Test it
Microsoft Confidential
Auto Close
• OFF by default.
Microsoft Confidential
Auto Create Statistics
• ON by default.
Microsoft Confidential
Auto Update Statistics
• ON by default.
Microsoft Confidential
Auto Update Statistics Asynchronously
• OFF by default.
Microsoft Confidential
Demonstration: Configuring
auto options
Lesson Knowledge Check
Microsoft Confidential
Module 5: Managing SQL
Server Databases
Microsoft Confidential 34
Recovery Models
Recovery Model
Page Verify
Deprecated
in SQL 2012 Recommended!
Torn Page
None Checksum
Detection
Microsoft Confidential
Compatibility Level
• Affects database behavior.
Microsoft Confidential
Is compatibility level 80 (SQL Server 2000) supported in SQL Server 2012?
Microsoft Confidential
Collation
• Sorting rules, case and accent sensitivity
* Latin1_General = ASCII encoding
* CP1 = Code Page 1
* CI = Case Insensitive
* AS = Accent Sensitive
Microsoft Confidential
Demonstration: Configuring
database options
Lab: Configure a user
database as per best practices
Lesson Knowledge Check
What is the default page verify value for a database in SQL 2012?
Microsoft Confidential
Module 5: Managing SQL Server
Databases
Microsoft Confidential 45
Storage Best Practices
Microsoft Confidential
Storage Best Practices
Microsoft Confidential
Tempdb Best Practices
For > 8 logical processors, start with 8 and increase by 4 if contention continues
• Set the size of tempdb to an appropriate value
Microsoft Confidential
Partition Alignment Best Practices
Microsoft Confidential
Instant File Initialization
Microsoft Confidential
Lab: Configure tempdb
database
Lesson Knowledge Check
What is the preferred file allocation unit size for SQL Server?
Microsoft Confidential
Module 5: Managing SQL Server
Databases
Microsoft Confidential 55
Login
• Types:
SQL
Windows
Microsoft Confidential
User
Microsoft Confidential
Logins and Users
Microsoft Confidential
DBO and Guest User
DBO
• Performs all activities in the database
Guest
• Allows logins without user accounts to access database
Microsoft Confidential
What is the guest user useful for?
Microsoft Confidential
Demonstration: Managing
guest user access
Roles
Server Roles
Database Roles
Application roles
Microsoft Confidential
What is the public server role?
Microsoft Confidential
Demonstration: Create a
user-defined server role
Lesson Knowledge Check
Why must you take care while granting permissions to Public server role?
Microsoft Confidential
67
Microsoft Confidential