Skip to main content

Configure Recovery Models

A recovery model is a database configuration option that controls how transactions are
logged, whether the transaction log is backed up, and what restore options are available
for the database. The recovery model you choose for your database has both data recovery
implications and performance implications, based on the logging the recovery
model performs or doesn’t perform.

There are:
  • Simple recovery model
  • Full recovery model
  • Bulk-Logged recovery model 

--Configure Recovery Models
SELECT name, recovery_model_desc FROM sys.databases
alter database dbname set recovery full
/*Full recovery is the recommended model for a production database
because it provides the most recoverable configuration. If you import data periodically
by using a bulk mechanism, you can temporarily change the recovery model for
your database to Bulk-Logged to get better bulk-load performance. Then, when the
import process ends, return your database to the Full recovery model.*/
-------******------
/*1. Set the database recovery model for the AdventureWorks database to Bulk-
Logged by executing the following ALTER DATABASE statement. (Before changing
the recovery model, do a full backup of the database.)
-- Note that you should create the C:\Backup folder at Operating System level before
running this backup. */
BACKUP DATABASE AdventureWorks TO DISK='C:\Backup\AdventureWorks.Bak'
GO
--Change the Recovery Model to Bulk Logged
ALTER DATABASE AdventureWorks SET RECOVERY BULK_LOGGED
/*2. Type and then run the following ALTER DATABASE statement to change the
recovery model back to Full after performing the bulk-logged operations; perform
another full database backup so that you have a backup of the data that
was just loaded:*/
ALTER DATABASE AdventureWorks SET RECOVERY FULL
--Perform a Full database backup
BACKUP DATABASE AdventureWorks TO DISK='C:\Backup\AdventureWorks.Bak'
GO

Comments

Popular posts from this blog

Different types of Database Restore option

RESTORE FILELISTONLY retrieves the list of database and log files in the backup. RESTORE HEADERONLY returns header information about all backup sets on the supplied backup device. Although this command returns a wealth of information, typically you will only examine a small portion of it. For instance, it might be beneficial to know a backed up database’s collation, type of backup, first and last Log Sequence Numbers and database compatibility level. RESTORE FILELISTONLY FROM DISK = 'e:\telefullbkp' RESTORE HEADERONLY FROM DISK = 'e:\telefullbkp' RESTORE FILELISTONLY FROM DISK = 'D:\backup\Banking_20120929192001.trn' RESTORE HEADERONLY FROM DISK = 'D:\backup\Banking_20120929192001.trn' ********************************************************************************************* /* restore the full backup first with NO RECOVERY */ RESTORE DATABASE pubs FROM DISK = 'e:\pubs.bak' WITH...

All about View in SQL Server

View :: Any relation which is not part of logical model,but is made visible to a user as a virtual relation, is called a view. --CREATE VIEW [ schema_name . ] view_name [ (column [ ,...n ] ) ] [ WITH <view_attribute> [ ,...n ] ] AS select_statement [ ; ] [ WITH CHECK OPTION ] < view_attribute > ::= { [ ENCRYPTION ] [ SCHEMABINDING ] [ VIEW_METADATA ] } ----------------------------------------------------------------------------------------- ENCRYPTION : The definition of an encrypted view is not visible to anyone, including a member of the sysadmin fixed server role.cannot decrypt the definition. SCHEMABINDING : cannot drop any tables, views, or functions referenced by the view without first dropping the view. VIEW_METADATA : ----------------- Example:CREATE VIEW v_CustomerAddress AS SELECT a . CustomerID , a . CustomerName , c . AddressLine1 , c . AddressLine2 , c . AddressLine3 , c . City , d . StateProvince , c . P...

How to install SQL Server 2005 step by step

How to install SQL Server 2005 step by step