Tải bản đầy đủ (.pdf) (16 trang)

Instructor InputsSession 7..Session OverviewThis session includes the following topics: pot

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (1 MB, 16 trang )

Instructor Inputs
Session 7

¤NIIT Instructor Inputs 7.3
This session includes the following topics:
 Detaching and attaching a database
 Restore operation
 Best practices
 Tips and Tricks
 FAQs
Slide 1
Installing Windows XP Professional Using Attended Installation
Slide 1 of 16
Ver. 1.0
Querying, Managing, and Administering Databases Using SQL Server 2005
Collaborate Session 7
Objectives
In this session, you will learn about:
Detaching and attaching a database
Restore operation
Best practices that can be considered while managing
databases and database objects using SQL Server 2005
Tips and tricks will help you to effectively manage database
and database objects using SQL Server 2005
FAQs related to database files and filegroups of SQL Server
2005
Session Overview
7.4 Instructor Inputs ¤NIIT
Slide 2
Installing Windows XP Professional Using Attended Installation
Slide 2 of 16


Ver. 1.0
Querying, Managing, and Administering Databases Using SQL Server 2005
Colla borate Session 7
Knowledge Byte
Detaching a database is the same as logically removing the
database from the SQL Server.
A SQL Server 2005 database can be detached by using:
SQL Server Management Studio
T-SQL
To move a database from an instance of SQL Server, you
can detach it from one instance and attach it to another
instance.
You can attach a database by using:
SQL Server Management Studio
T-SQL
The process of retrieving data from a backup and applying
transaction log to the data is called as restoring.
Slide 3
Installing Windows XP Professional Using Attended Installation
Slide 3 of 16
Ver. 1.0
Querying, Managing, and Administering Databases Using SQL Server 2005
Colla borate Session 7
Knowledge Byte (Contd.)
The process of rolling forward uncommitted transactions, if
any, and bringing the database online is known as recovery.
In a restore process, the logged changes are applied to the
data in a database to retrieve the data on time. This process
is known as rolling forward and the set of data restored is
known as roll forward set.

Each restore scenario is implemented by using one or more
restore steps (operations), called a restore sequence.
A restore operation is a multiphase process. The possible
phases of a restore process are:
Data copy phase
Redo phase
Undo phase
¤NIIT Instructor Inputs 7.5
Slide 4
Installing Windows XP Professional Using Attended Installation
Slide 4 of 16
Ver. 1.0
Querying, Managing, and Administering Databases Using SQL Server 2005
Collaborate Session 7
Best Practices
While creating your own database objects, ensure that you
do not create the database objects in the system databases
like master database.
While moving master database and log files to another
location, ensure that you also move the Resource database
to the same location.
While restoring the Resource database you must be careful
not to overwrite the current Resource database with an out-
of-date or potentially insecure version of Resource
database.
Slide 5
Installing Windows XP Professional Using Attended Installation
Slide 5 of 16
Ver. 1.0
Querying, Managing, and Administering Databases Using SQL Server 2005

Collaborate Session 7
Best Practices (Contd.)
The size of tempdb can affect the performance of a system.
If the size of the tempdb is less than the requirement of the
server, it would have an impact on the performance of the
server. A good practice is to increase the size of tempdb.
It is not a good idea to shrink a database if the database has
frequent updations. In these cases, shrinking a database is
a wasted operation.
7.6 Instructor Inputs ¤NIIT
Slide 6
Installing Windows XP Professional Using Attended Installation
Slide 6 of 16
Ver. 1.0
Querying, Managing, and Administering Databases Using SQL Server 2005
Colla borate Session 7
Tips and Tricks
Backup the master database after performing the following
operations:
Creating, modifying, or dropping a database
Changing server and database configuration values
Modifying or adding logon accounts
After restoring a backup of mssqlsystemresource.mdf, it is a
good practice to reapply any subsequent updates.
After you add or delete files in a database, create a
database backup immediately.
If you have to create multiple secondary files in your
database, create them in a separate filegroup.
Do not put the Resource database in either compressed or
encrypted NTFS file system folders.

Slide 7
Installing Windows XP Professional Using Attended Installation
Slide 7 of 16
Ver. 1.0
Querying, Managing, and Administering Databases Using SQL Server 2005
Colla borate Session 7
Can you change the owner of the master database?
You cannot change the owner of master database as it is
owned by dbo.
FAQs
¤NIIT Instructor Inputs 7.7
Slide 8
Installing Windows XP Professional Using Attended Installation
Slide 8 of 16
Ver. 1.0
Querying, Managing, and Administering Databases Using SQL Server 2005
Collaborate Session 7
Can master database be dropped?
No, you cannot drop master database as it is a system
database.
FAQs (Contd.)
Slide 9
Installing Windows XP Professional Using Attended Installation
Slide 9 of 16
Ver. 1.0
Querying, Managing, and Administering Databases Using SQL Server 2005
Collaborate Session 7
While creating objects in a database if user does not specify
the filegroup, which filegroup are objects assigned to?
The objects are by default assigned to default filegroup. The

primary filegroup is the default filegroup.
FAQs (Contd.)
7.8 Instructor Inputs ¤NIIT
Slide 10
Installing Windows XP Professional Using Attended Installation
Slide 10 of 16
Ver. 1.0
Querying, Managing, and Administering Databases Using SQL Server 2005
Colla borate Session 7
What are the three types of files used to store a database?
Which of these files are must for a database?
The three types of files to store a database are primary files,
secondary files, and transaction files. A database must have a
primary file and atleast one transaction log file.
FAQs (Contd.)
Slide 11
Installing Windows XP Professional Using Attended Installation
Slide 11 of 16
Ver. 1.0
Querying, Managing, and Administering Databases Using SQL Server 2005
Colla borate Session 7
Can transaction log files be a part of any filegroup?
No, transaction log file are never a part of any filegroup.
FAQs (Contd.)
¤NIIT Instructor Inputs 7.9
Slide 12
Installing Windows XP Professional Using Attended Installation
Slide 12 of 16
Ver. 1.0
Querying, Managing, and Administering Databases Using SQL Server 2005

Collaborate Session 7
Challenge
Which of the following statement is NOT correct about
detaching a database?
It’s a logical removal of database from the server
A detached database can be attached to a SQL Server in the
same computer
Using the SQL Server Management Studio you can detach a
database
A detached database cannot be attached to SQL Server of
another computer
Answer:
A detached database cannot be attached to SQL Server
of another computer
Slide 13
Installing Windows XP Professional Using Attended Installation
Slide 13 of 16
Ver. 1.0
Querying, Managing, and Administering Databases Using SQL Server 2005
Collaborate Session 7
Challenge (Contd.)
Which T-SQL procedure is used to detach a database?
sp_detach_db
sp_detach
sp_db_detach
sp_detachdb
Answer:
sp_detach_db
7.10 Instructor Inputs ¤NIIT
Slide 14

Installing Windows XP Professional Using Attended Installation
Slide 14 of 16
Ver. 1.0
Querying, Managing, and Administering Databases Using SQL Server 2005
Colla borate Session 7
Challenge (Contd.)
Which of the following statement will detach the
AdventureWorks and execute the UPDATE STATISTIC
process?
sp_detach_db 'AdventureWorks', 'TRUE'
sp_detach_db 'AdventureWorks', ‘NULL’
sp_detach 'AdventureWorks', 'TRUE'
sp_detach 'AdventureWorks', 'NULL'
Answer:
sp_detach_db 'AdventureWorks', ‘NULL’
Slide 15
Installing Windows XP Professional Using Attended Installation
Slide 15 of 16
Ver. 1.0
Querying, Managing, and Administering Databases Using SQL Server 2005
Colla borate Session 7
Challenge (Contd.)
In which condition CREATE DATABASE with FOR ATTACH
clause is used?
When the database is detached using sp_detach_db
statement
When the database is detached using SQL Server
Management Studio
When the number of data files to be attached is more than 16
When the database needs to be attached to a server on a

different computer
Answer:
When the number of data files to be attached is more
than 16
¤NIIT Instructor Inputs 7.11
Slide 16
Installing Windows XP Professional Using Attended Installation
Slide 16 of 16
Ver. 1.0
Querying, Managing, and Administering Databases Using SQL Server 2005
Collaborate Session 7
Challenge (Contd.)
Which phase of restore process is skipped if the data is
already transactionally consistent at the start of the recovery
process?
Redo Phase
Data Copy Phase
Undo Phase
Roll Forward Phase
Answer:
Undo Phase
7.12 Instructor Inputs ¤NIIT
1. d. A detached database cannot be attached to SQL Server of another computer.
2. a.
sp_detach_db
3. b. sp_detach_db 'AdventureWorks', ‘NULL’
4. c. When the number of data files to be attached is more than 16
5. c. Undo Phase
Solutions to Challenge
¤NIIT Instructor Inputs 7.13

1. Which of the following statement is true about log files?
a. These file are used to recover a database
b. These files have an extension of .ndf
c. A database can have only one log file
d. The minimum size of log files is 256 MB
2. Which of the following commands will remove the filegroup fg1 from the database
db1?
a. ALTER DATABASE db1 REMOVE FILE fg1
b. ALTER DATABASE db1 REMOVE fg1
c. ALTER DATABASE db1 REMOVE FILEGROUP fg1
d. ALTER FILEGROUP fg1 REMOVE FILEGROUP fg1 FROM db1
3. Which of the following commands will show the information for the emp_sts
statistics on the Event table?
a. DBCC SHOW_STATISTICS ('db1.Event', emp_sts)
b. DBCC SHOW_CONTIG ('db1.Event', emp_sts)
c. sp_helpstats ('db1.Event', emp_sts)
d. sp_helpstats 'db1.Event', ‘emp_sts’
4. Which of the following command checks for the consistency of disk space allocation
structures for a particular database?
a. DBCC CHECKDBALLOC
b. DBCC CHECKALLOC
c. DBCC CHECKTABLE
d. DBCC CHECKMEM
5. Which of the following is NOT a schedule type available in the New Job Schedule
dialog box?
a. Recurring
b. First time
c. Start automatically when SQL Server Agent starts
d. Start whenever CPU become idle
6. Which of the following principal allows log on to an instance of the SQL Server?

a. Windows
b. Database
c. Server
d. System
Home Assignment
7.14 Instructor Inputs ¤NIIT
7. Which scope of SQL Server level securable includes the tables, views, procedures
and functions?
a. Sever scope
b. Database scope
c. Schema scope
d. Windows scope
8. Which parameter of CREATE LOGIN statement specifies the GUID of the new SQL
Server login?
a. GUID
b. SID
c. PASSWORD
d. HASHED
9. Which of the following fixed database role allows adding, modifying, and dropping
database objects?
a. db_accessadmin
b. db_owner
c. db_ddladmin
d. db_securityadmin
10. Which of the following is a database level permission?
a. ALTER ANY DATABASE
b. VIEW ANY DATABASE
c. VIEW DATABASE STATE
d. BACKUP DATABASE
Solutions

1. These file are used to recover a database
2. ALTER DATABASE db1 REMOVE FILEGROUP fg1
3. DBCC SHOW_STATISTICS ('db1.Event', emp_sts)
4. DBCC CHECKALLOC
5. First time
6. Server
7. Schema scope
8. SID
9. db_ddladmin
10. BACKUP DATABASE
¤NIIT Instructor Inputs 7.15
After SQL Server installation and database and database objects creation, you as a
database administrator need to decide on the security of the data and database server.
Security means restricting access to data and database server by granting and denying
access to database and its objects to the right person at right time.
Discuss the basic components of SQL Server that are used in implementing security such
as users and logins.
Instructor Inputs
You can conduct the discussion as follows:
 Discuss the principals, securables, and permissions to secure data and database
server.
 Also discuss role of encryption in securing data.
Solution
To secure a database server the SQL server provides the different components to apply
security at different levels. In addition the data and messages in server can also be
encrypted to provide security.
Using SQL Server components to secure the database server
The SQL Server provides a set of components, such as principals, securables, and
permissions, which can be used to apply security at different levels.
Principals

Principals are logical entities that need to access the resources of the SQL Server. These
entities include computer accounts, logins, and user accounts used to access the data in
the database. Principals can be given permission to access an object, such as tables or
views
, in the database system.
Principals can exist at three levels:
 Windows
 Server
 Database
Collaborative Exercise
7.16 Instructor Inputs ¤NIIT
Securables
Securables are objects that are accessed by the principals. Securables can exist at the
following levels:
 Windows level
 SQL Server level
Permissions
You can allow or disallow principals to access the securables by setting permissions.
Permissions govern the level of access that principals have on the securables. Depending
on the role, different users can perform different actions on the database.
Using encryption to secure data and messages
In addition to restricting access to database and database objects, you can add one more
layer of security by encrypting data. You can encrypt data and complete database objects,
such as procedures or functions, by using keys and certificates. A key is a value that can
be applied to a cryptographic function to encrypt or decrypt a secure data value.
A digitally signed certificate ensures that the message should not be intercepted and read
by third party. It also ensures that the message is not tampered or the sender’s identity
altered.
After creating the keys and certificates, you can use keys and certificates to encrypt data
and implement security. You can encrypt the data stored in a table or you can save a

function or stored procedure in an encrypted format.

×