0% found this document useful (0 votes)
9 views

171_Ch05_06_Creating03

Uploaded by

juju0190
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

171_Ch05_06_Creating03

Uploaded by

juju0190
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

1

Chapter 05: Video 06

Creating a
Database: Sizing
and Configuring
Database Files
Chapter: Creating and Managing Databases
Course: SQL Server 2012 Database Administration
Course ID: 171
Instructor: Scott Whigham

1 p. 1
2

Database file manipulation is a task


that all DBAs need to know:
– Expanding a file
– Removing a file
– Adding additional files
– Shrinking a file
– Let’s talk about expanding!

2 p. 2
3

A basic Transact-SQL script:

3 p. 3
4

First thing to know:


– Each file is known internally by a logical file
name
– All file manipulation is done by referring to
the logical file name
• Not the physical file name!

4 p. 4
5

Logical file names are highlighted:

5 p. 5
6

Physical file names and locations


can change, but the database has to
be taken offline to do so
– We can change physical file name and/or
location when:
• We attach a database
• We restore a database
• We stop SQL Server
• (We’ll do these later in the course!)

6 p. 6
7

Autogrowth is a safety net


– If a file gets 100% full, the file will grow if
Autogrowth is enabled
– Tips:
• 1) Enable Autogrowth
• 2) Set it to a “decent size”
• 3) Try not to let it happen!

7 p. 7
8

Autogrowth parameters:
– Grow the file by either:
• A percentage of current size
• A fixed amount (in MB)
– Tips:
• Always set a maximum size
• Autogrowth is a blocking operation unless Instant
File Initialization is enabled
– More on IFI later in this chapter...

8 p. 8
9

FILEGROWTH is Autogrowth:

9 p. 9
10

Best practices for creating


databases:
– Create the database the size that you expect
it to be in 12‐18 months
• This prevents autogrowth from happening during
peak hours
– Do allow autogrowth
• Keep parameters small and easy so that database can
grow quickly and be usable quickly

10 p. 10
11

Best practices for creating


databases (cont.):
– Have a plan for growing the database in 12‐18
months (or before Autogrowth kicks in)
– Always, always keep an eye on the file sizes
• Particularly the transaction log

11 p. 11
12

Expanding a file is easy and


dynamic
– You can manually increase your data and log
files at any time
– We’ll look at working with multiple files in
an upcoming video

12 p. 12
13

Expanding a file with TSQL:


– ALTER DATABASE is an important
command
– Note the use of the logical file name

13 p. 13
14

Don’t forget!
– You can use SSMS to learn your TSQL
• Make your changes in SSMS then click Script

14 p. 14
15

In the next video…


– Expanding a Database

“Rules are for the guidance of wise men and the obedience of fools.”
- Douglas Bader

15 p. 15

You might also like