Академический Документы
Профессиональный Документы
Культура Документы
by Brent Ozar it's the simplest way to get the point across
in a tiny email. Hey, you try teaching tough
If you're doing transaction concepts in a page or two, buddy.)
log backups, forget using the If disaster strikes at 8:15AM and I lose the
GUI. Even if you only have server, I need to restore the full, the most
one transaction log backup recent dierential, and the transaction logs
per hour, it'll take you way that follow the dierential, like this:
too long to click through all the les.
MyDatabase_20130718_0000.bak
Think about what your backup folder might
look like if we named our backup les by MyDatabase_20130718_0600.dif
database, date, time, and a dierent MyDatabase_20130718_0700.trn
extension per type of backup (BAK for fulls,
DIF for dierentials, and TRN for transaction MyDatabase_20130718_0800.trn
logs): That's a really easy script to write - and
thankfully, MSSQLTips has already done it.
MyDatabase_20130718_0000.bak
Just change the variables for your database
MyDatabase_20130718_0100.trn name and the path where your restore les
MyDatabase_20130718_0200.trn live, and presto, the script will restore all of
the les for you automatically.
MyDatabase_20130718_0300.trn
This Script Has Implications For You
MyDatabase_20130718_0400.trn
You need to back up your databases
MyDatabase_20130718_0500.trn intelligently.You want to put each database
MyDatabase_20130718_0600.dif in its own folder, and you want the le names
to have the database name and the time in
MyDatabase_20130718_0700.trn them. I'm a big fan of that anyway - it makes
MyDatabase_20130718_0800.trn life easier when I want to quickly scan and
In that scenario, I took my full backup at see what backups have been done.
midnight, then hourly It assumes the same database
transaction logs, path when you restore. If you're
with dierential Knowing how youll the kind of DBA who likes to
backups every 6 change drive letters and folders
hours. (This is never
restore aects how all the time, or you've got les
a scenario I'd use in you back up. scattered all over the place, and
the real world, but your production and
Then, try out theMSSQLTips restore Our Backup Video Archive: no, its not a
scriptto make sure you can quickly restore a backup of our videos - its our videos about
database from scratch into a development or backups. We talk database mirroring,
staging environment. If you get errors, leave clustering, AlwaysOn Availability Groups,
comments on that blog post describing the and more.
error, and ideally, contribute your script
improvements back in. Now, when disaster
strikes, you won't be clicking around blindly
High denition
video training on
your desktop,
laptop, or even
your iPad.
brentozar.com/go/any
These solutions are typically six gures and Check out Denny Cherry's book Securing
up. They're expensive because they have to SQL Server (paperback - Kindle). Denny
be absolutely bulletproof - if they fail, you manages to bring a very dry topic to life.
can't have the access to the database Every shop with PCI, HIPAA, SOX, or other
suddenly stop. Plus, you'll need them in compliance needs should denitely own a
place for not just your production copy of this book. It's a tougher sell for small
environment, but also your disaster recovery shops with only one full time DBA, though,
environment. because a lot of the security features
If you just want to check a box and make the discussed take time to digest and
auditors think you're secure, that's easy and implement.
by Brent Ozar
Weve covered
backups and security,
except...
Well, we havent.
We could go on for
hundreds of pages about those two
levels alone. We could ll entire ebooks,
perhaps even libraries, with cool
concepts like how the dierential
bitmap works, how to secure stored
procedures with certicates, how to
congure SQL Server when using
VMware-based backups for storage
replication, how to recover from a
corrupted nonclustered index, yadda
yadda yadda. Trivial Pursuit category youre hot on this
Our point of this ebook is a fast start. week. We just cant cover it all in one ebook.
Your journey in SQL Server database When you nd an area that you want to dig
administration is never really done. Youre deeper into, check out:
going to be learning for the rest of your life, Our video training courses - from our $29
and even when you think youre done, youre 90-minute courses all the way up to our 5-6
only mistaken. Heck, Im a Microsoft hour monsters at $299, we can go much
Certied Master, and I still learn things in deeper. Some even include quizzes!
almost every presentation I attend. (Except
Our in-person classes - we have 2-3 day
Jeremiahs, because Im not smart enough
courses for developers and DBAs who need
to digest that stu.)
to make SQL Server faster and more
So were going to move up a level to reliable.
capacity, but please dont email us with cries
Our SQL Critical Care - we work together
of complaints about how you wish we would
with you over WebEx or in person to
have gone deeper into clustering setups,
diagnose your SQL Servers pain points and
replication internals, or whatever other
train you on the xes.
1. You scan through pages looking at just But that's not always enough. Sometimes we
the letters at the top until you get close have more than one John Smith, and the
customer needs to know which John Smith
2. When you get close, you open up the full to call. After all, if your name was John
book and jump to the right letters Smith, and the phone book didn't include
3. You can quickly nd the right single one your address, you'd get pretty tired of
record answering the phone and saying, "No, you
want the John Smith on Red Road. He's
Now think about how you would do it without 305-838-3333." So we would add the
the White Pages. Think if you only had a Address 1 eld in there too.
book with 500,000 records in it, organized
by phone number. You would have to scan Billing contact last name
through all 500,000 records and check the Billing contact rst name
last name and rst name elds. The
database works the same way, except it's Address 1
even worse! If a developer wrote a SQL Phone number
query looking for the phone number, it would
Do we absolutely need the address in our
look like this:
index for every query? No, but we include it
for convenience because when we DO need
SELECT
PhoneNumber
FROM
Directory
WHERE
it, we need it bad. And if we DON'T need it, it
LastName
=
'Smith'
AND
FirstName
=
doesn't really hurt us much.
'John' This is called a covering index because it
covers other elds that are useful. Adding
the address eld to our index does make it
That doesn't say select the top one - it says larger. A phone book without addresses
select ALL of them. When you, as a human would be a little thinner, and we could pack
being, go through that list of 500,000 phone more on a page. We probably don't want to
numbers, you would stop when you thought include the Address 2 eld, because the
you found the right John Smith. The Address 1 eld is enough to get what we
database server can't do that - if it nds need. The database administrator has to
John Smith at row #15, it doesn't matter, make judgement calls as to which elds to
because there might be a few John Smiths. use on a covering index, and which ones to
Wh
w an t an I prefer I prefer the o ar
I
x on ordering fr
om ordering trucks se e
inde rant s. pe
u
resta es. food truck of food. op
le?
tabl