Module 4 Working with Databases. Module Overview Overview of SQL Server Databases Working with Files and Filegroups Moving Database Files.

Slides:



Advertisements
Similar presentations
Transaction Log file:.ldf Extent: 8 contiguous 8KB pages Page: 8KB Primary Data file:.mdf Secondary data file:.ndf Primary Data file:.mdf Secondary.
Advertisements

Module 12: Auditing SQL Server Environments
Module 17 Tracing Access to SQL Server 2008 R2. Module Overview Capturing Activity using SQL Server Profiler Improving Performance with the Database Engine.
Week 6: Chapter 6 Agenda Automation of SQL Server tasks using: SQL Server Agent Scheduling Scripting Technologies.
Brad M McGehee Microsoft SQL Server MVP Director of DBA Education Red Gate Software
Module 20 Troubleshooting Common SQL Server 2008 R2 Administrative Issues.
Module 7 Restoring SQL Server 2008 R2 Databases. Module Overview Understanding the Restore Process Restoring Databases Working with Point-in-time Recovery.
Module 3 Installing and Configuring SQL Server 2008 R2.
SQL Server 2005 Implementation and Maintenance Chapter 10: Maintaining and Automating SQL Server.
Database Optimization & Maintenance Tim Richard ECM Training Conference#dbwestECM Agenda SQL Configuration OnBase DB Planning Backups Integrity.
SharePoint and SQL Server integration Demo: SQL Server Optimizing Configurations SQL Server 2014 for SharePoint 2013 Avoiding ginormous transaction.
Module 3: Creating and Managing Databases. Overview Creating Databases Creating Filegroups Managing Databases Introduction to Data Structures.
Harvard University Oracle Database Administration Session 5 Data Storage.
Microsoft SQL Server Administration for SAP SQL Server Architecture.
Proper Care and Feeding of your SQL MDB -Recommendations for General MDB Maintenance -Read the notes on the foils! -Revised October
Module 5 Understanding SQL Server 2008 R2 Recovery Models.
Working with SQL and PL/SQL/ Session 1 / 1 of 27 SQL Server Architecture.
Database Configuration and Maintenance Database Configuration and Maintenance Exam / 30.
Transaction log grows unexpectedly
1 Chapter Overview Transferring and Transforming Data Introducing Microsoft Data Transformation Services (DTS) Transferring and Transforming Data with.
Optimizing SQL Server 2012 for SharePoint 2013 SharePoint Saturday/Friday, Honolulu March 27, 2015.
Session 7 Creating and Managing Databases. RDBMS and Data Management/ Session 7/2 of 27 Session Objectives Describe the system and user-defined databases.
Chapter 2 Administrating DB Engine. Database Engine  The Database Engine is the core service for storing, processing, and securing data.  It provides.
Module 13 Automating SQL Server 2008 R2 Management.
Module 8: Server Management. Overview Server-level and instance-level resources such as memory and processes Database-level resources such as logical.
Module 1: Installing Active Directory Domain Services
Course 6425A Module 9: Implementing an Active Directory Domain Services Maintenance Plan Presentation: 55 minutes Lab: 75 minutes This module helps students.
Module 18 Monitoring SQL Server 2008 R2. Module Overview Monitoring Activity Capturing and Managing Performance Data Analyzing Collected Performance Data.
Chapter 10 : Designing a SQL Server 2005 Solution for High Availability MCITP Administrator: Microsoft SQL Server 2005 Database Server Infrastructure Design.
1 Chapter Overview Creating a User Database Setting Database Options Managing User Database Size Placing Database Files on Multiple Disks.
Chapter 4 SQL. SQL server Microsoft SQL Server is a client/server database management system. Microsoft SQL Server is a client/server database management.
Implementing File and Print Services
Chapter 2: Designing Physical Storage MCITP Administrator: Microsoft SQL Server 2005 Database Server Infrastructure Design Study Guide (70-443)
Database Administration TableSpace & Data File Management
Module 3: Managing Database Files. Overview Introduction to Data Structures Creating Databases Managing Databases Placing Database Files and Logs Optimizing.
Chapter 18: Windows Server 2008 R2 and Active Directory Backup and Maintenance BAI617.
Extents, segments and blocks in detail. Database structure Database Table spaces Segment Extent Oracle block O/S block Data file logical physical.
Module 19 Managing Multiple Servers. Module Overview Working with Multiple Servers Virtualizing SQL Server Deploying and Upgrading Data-Tier Applications.
Agenda for Today Chapter 5 –Skip Lesson 2 Review questions Midterm Chapter 6 Review questions.
Databases Lesson 5.
Architecture Rajesh. Components of Database Engine.
Module 9 Authenticating and Authorizing Users. Module Overview Authenticating Connections to SQL Server Authorizing Logins to Access Databases Authorization.
Module 9 Planning a Disaster Recovery Solution. Module Overview Planning for Disaster Mitigation Planning Exchange Server Backup Planning Exchange Server.
Module 6 Backup of SQL Server 2008 R2 Databases. Module Overview Backing up Databases and Transaction Logs Managing Database Backups Working with Backup.
Module 14 Configuring Security for SQL Server Agent.
Module 16: Performing Ongoing Database Maintenance
Module 10 Assigning Server and Database Roles. Module Overview Working with Server Roles Working with Fixed Database Roles Creating User-defined Database.
1 Chapter Overview Preparing to Upgrade Performing a Version Upgrade from Microsoft SQL Server 7.0 Performing an Online Database Upgrade from SQL Server.
1 Chapter Overview Performing Configuration Tasks Setting Up Additional Features Performing Maintenance Tasks.
Module 15 Monitoring SQL Server 2008 R2 with Alerts and Notifications.
Week 7 : Chapter 7 Agenda SQL 710 Maintenance Plan:
Module 1: Implementing Active Directory ® Domain Services.
SQL Server 2000 Sys Admin Jeremiah Curtis Engineering Services
Module 4 Planning for Group Policy. Module Overview Planning Group Policy Application Planning Group Policy Processing Planning the Management of Group.
Module 1 Introduction to SQL Server® 2008 R2 and its Toolset.
Connect with life Vinod Kumar Technology Evangelist - Microsoft
Module 12: Configuring and Managing Storage Technologies
Module 11: Managing Transactions and Locks
Hands-On Microsoft Windows Server 2008 Chapter 7 Configuring and Managing Data Storage.
SQL Server 2012 Session: 1 Session: 6 Creating and Managing Databases Data Management Using Microsoft SQL Server.
Log Shipping, Mirroring, Replication and Clustering Which should I use? That depends on a few questions we must ask the user. We will go over these questions.
Introduction to SQL Server  Working with MS SQL Server and SQL Server Management Studio.
In this session, you will learn to: Manage databases Manage tables Objectives.
Partial Database Availability
A Technical Overview of Microsoft® SQL Server™ 2005 High Availability Beta 2 Matthew Stephen IT Pro Evangelist (SQL Server)
Designing Database Solutions for SQL Server
Automating SQL Server Management
Hitting the SQL Server “Go Faster” Button
Real world In-Memory OLTP
Ch 10. Maintaining and Automating SQL Server
Presentation transcript:

Module 4 Working with Databases

Module Overview Overview of SQL Server Databases Working with Files and Filegroups Moving Database Files

Lesson 1: Overview of SQL Server Databases How Data is Stored in SQL Server Determining File Placement and Number of Files Ensuring Sufficient File Capacity System Databases Supplied with SQL Server Overview of tempdb Demonstration 1A: Working with tempdb

How Data is Stored in SQL Server Transaction Log file:.ldf Extent: 8 contiguous 8KB pages Page: 8KB Primary Data file:.mdf Secondary data file:.ndf Primary Data file:.mdf Secondary data file:.ndf Table and Index data is stored in Pages that are grouped in Extents. Special allocation pages keep track of page usage.

Determining File Placement and Number of Files Isolate log and data files at the physical disk level Use appropriate RAID levels Determine the number and location of data files based on performance and maintenance considerations  Use additional files to spread data over more spindles or storage locations  Use smaller data files when easier maintenance is needed  Use data files as units of backup and restore Determine log file requirements  Use a single log file in most situations as log files are written sequentially

Ensuring Sufficient File Capacity Estimate the size of data, log files and tempdb  Perform load testing with the actual application  Check with the database vendor Set the size to a reasonable size:  Leave enough place for new data, without the need to expand often  Monitor data and log file usage  Plan for manual expansion  Keep autogrowth enabled to allow for unexpected growth

System Databases Supplied with SQL Server System DatabaseDescription masterStores all system-level configuration msdb Holds SQL Server Agent configuration including job, backup and restore history modelIs the template for new databases tempdb Holds temporary data like temporary tables, table variables, hash tables and the row version store resource Hidden read-only database that contains system objects that are mapped to the sys schema of databases

Overview of tempdb tempdb contains temporary data for internal objects, row versioning, and user objects  Is truncated or rebuilt with every restart of the instance  Occupies space depending upon workload and usage patterns on the SQL Server instance  Should be tested with real-life workloads Place tempdb on a fast and separate I/O subsystem to ensure good performance  Split tempdb into data files of equal size per core (up to a maximum of about 8 data files)  Use testing to confirm the best value

Demonstration 1A: Working with tempdb In this demonstration, you will see how the size of the tempdb database files is managed.

Lesson 2: Working with Files and Filegroups Creating User Databases Configuring Database Options Instant File Initialization Demonstration 2A: Creating Databases Altering Databases Expanding and Shrinking Database Files Demonstration 2B: Altering Databases Working with Filegroups Demonstration 2C: Filegroups

Creating User Databases Can be created in GUI Can be created with CREATE DATABASE T-SQL command Collation can be specified CREATE DATABASE Branch ON ( NAME = Branch_dat, FILENAME = 'D:\Data\Branch.mdf', SIZE = 100MB, MAXSIZE = 500MB, FILEGROWTH = 20% ) LOG ON ( NAME = Branch_log, FILENAME = 'L:\Logs\Branch.ldf', SIZE = 20MB, MAXSIZE = UNLIMITED, FILEGROWTH = 10MB ); CREATE DATABASE Branch ON ( NAME = Branch_dat, FILENAME = 'D:\Data\Branch.mdf', SIZE = 100MB, MAXSIZE = 500MB, FILEGROWTH = 20% ) LOG ON ( NAME = Branch_log, FILENAME = 'L:\Logs\Branch.ldf', SIZE = 20MB, MAXSIZE = UNLIMITED, FILEGROWTH = 10MB );

Configuring Database Options Database-level options are unique to each database OptionDescription Auto Options Define whether some operations should occur automatically within the database Page Verify Define how the page should be verified when read from disk. Should be set to CHECKSUM Recovery ModelDefines the recovery model of the database State options Sets the state of the database, such as Online/Offline, Restricted Access or Read Only Important database options:

Instant File Initialization Allows reclaiming used disk space quickly Does not require first filling that space with zeros Is a minor security concern Is enabled by assigning the SQL Server service account the Perform Volume Maintenance Tasks permission Applies only to data files  Does not apply to log files

Demonstration 2A: Creating Databases In this demonstration you will see how to create a database using the GUI in SSMS and using the CREATE DATABASE statement in T-SQL.

Altering Databases Database files can be added, dropped, expanded, and shrunk All file operations are online operations using  SSMS  ALTER DATABASE  DBCC (options such as CHECKDB and SHRINKFILE) Dropping a database file requires it to be emptied first  Need to migrate data to other files

Expanding and Shrinking Database Files Files can be expanded manually Files can grow automatically using the auto-growth options  Performed only when new place is needed  Can lead to blocking and time-out problems  Should be avoided: Plan for manual file expansion Shrinking files is possible  Uses DBCC SHRINKDATABASE, DBCC SHRINKFILE  Should be performed only when absolutely needed  Is a very intrusive operation  Can lead to heavily fragmented databases

Demonstration 2B: Altering Databases In this demonstration you will see:  How to add a file to a database  How to expand a database file  How to shrink a database file  How to drop a database file

Working with Filegroups Other Filegroups Other Filegroups Primary Filegroup Primary Filegroup Database Data File(s) *.mdf, *.ndf Data File(s) *.mdf, *.ndf Log File(s) *.ldf Log File(s) *.ldf Data File(s) *.ndf Data File(s) *.ndf Filegroups are named groups of database files that are used to control placement of database objects. Filegroups can be backed up or restored separately.

Demonstration 2C: Filegroups In this demonstration you will see:  How to create a database with several filegroups  How to create objects in filegroups

Lesson 3: Moving Database Files Overview of Detach and Attach Moving User Database Files Demonstration 3A: Detach and Attach Moving System Database Files Copying Databases Demonstration 3B: Moving and Reconfiguring tempdb

Overview of Detach and Attach Detaching a database drops the database from the instance  Data and log files are kept intact  Detached files can be attached again on the same or a different instance Use detach/attach to move databases to other instances  Detach/attach is also useful in disaster recovery situations

Moving User Database Files Data and log files can be moved within the instance  Can be performed using Detach/Attach  Preference is to use the ALTER DATABASE statement  Use Detach/Attach when moving between instances Logical name of the database files are needed  Used to identify the files to be moved Database needs to be set offline Files need to be moved manually within the filesystem

Demonstration 3A: Detach and Attach In this demonstration, you will see how to use detach and attach with database files.

Moving System Database Files All system databases except the resource database can be moved to new locations Moving the master database:  Startup parameters for the SQL Server services must be changed  Files must be moved manually while the instance is stopped Moving other system databases:  Use ALTER DATABASE as with user databases Be cautious performing these operations  Misconfiguration can prevent SQL Server from starting

Copying Databases There are different ways to copy databases:  Backup and Restore  Detach and Attach  Copy Database Wizard Copy Database Wizard  Can be used to move or copy databases between instances  Can copy additional objects the database depends on such as logins, jobs, maintenance plans, user-defined error messages and shared objects from the master database  Can be scheduled through a SQL Agent Job

Demonstration 3B: Moving and Reconfiguring tempdb In this demonstration, you will see how to move and reconfigure tempdb to have multiple files.

Lab 4: Working with Databases Exercise 1: Adjust tempdb configuration Exercise 2: Create the RateTracking database Exercise 3: Attach the OldProspects database Challenge Exercise 4: Add multiple files to tempdb (Only if time permits) Logon information Estimated time: 45 minutes

Lab Scenario Now that the Proseware instance of SQL Server has been installed and configured on the server, a number of additional database configurations need to be performed. As the database administrator, you need to perform these configuration changes. You need to create a new database on the server, based on requirements from an application vendor's specifications. A client has sent you a database that needs to be installed on the Proseware instance. Instead of sending you a backup, they have sent a detached database and log file. You need to attach the database to the Proseware instance. A consultant has also provided recommendations regarding tempdb configuration that you need to review and implement if appropriate.

Lab Review What is the biggest challenge where databases on a single server use different collations? Why should tempdb have multiple files on most systems?

Module Review and Takeaways Review Questions Best Practices