Wednesday, November 7, 2012

Recovery Models

Simple  Recovery Model:

The simple recovery model does not use the transaction log for recovery.

The transaction log can’t be backed up and is automatically truncated at checkpoints.
If you use the simple recovery model, you can only restore full database backups. The advantage to using the simple recovery model is that there is less transaction log management. 

Transactional replication, log shipping, or data mirroring is not allowed in the simple recovery model, as

there is no transaction log.

Disadvantages:
    Not for production systems
    Point in time recovery not possible
    Least data resistant recovery model

Syntax:
ALTER DATABASE <database_name
SET RECOVERY SIMPLE


Full Recovery Model:


The Full Recovery Model is the most resistant to data loss of all the recovery models.

The Full Recovery Model makes full use of the transaction log – all database operations are written to the transaction log. This includes all DML statements, but also whenever BCP or bulk insert is used.

Benefits:

    Most resistant to data loss
    Most flexible recovery options - including point in time recovery

Disadvantages:

    Can take up a lot of disk space
    Requires database administrator time and patience to be used properly

Recovery to a point of failure or point in time involves:

    Backing up the currently active transaction log
    Restoring the most recent full database backup without recovery
    Restoring the most recent differential database backup without recovery
    Restoring in sequence any transaction log backups without recovery
    Restoring the last transaction log backup with recovery

Syntax:
ALTER DATABASE <database_name
SET RECOVERY FULL


Bulk-Logged Recovery Model:


Databases using the bulk-logged recovery model minimally log bulk operations to the Microsoft SQL Server transaction log.

These operations include CREATE INDEX, SELECT … INTO, writetext, updatetext, and BULK INSERT.
The transaction log does not record sufficient information to recover these changes if media failure occurs after a bulk operation.
You can recover a database to the point of failure, but your data may not be consistent if it was changed by a bulk operation. The process of restoration is the same as that of full database recovery.

Syntax:
ALTER DATABASE <database_name> 
SET RECOVERY BulkLogged


No comments:

Post a Comment