Applies to: Microsoft SQL Server 2005 Enterprise and later.
Introduction.
This article provides a summary of the information available on Microsoft SQL Server Books Online about Database Snapshots.
Definition.
A snapshot is read-only, static view of a database.
Useful scenarios.
When not to use database snapshots.
Some important considerations about database snapshots.
Planning for Database Snapshots.
Creating a Database Snapshot.
Here is a sample database snapshot create script on the AdventureWorks database.
CREATE DATABASE AWDB_Snapshot_20080522 ON (
NAME = AdventureWorks_Data,
FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\AWDB_Snapshot.ss')
AS SNAPSHOT OF AdventureWorks;
Open SQL Server Management Studio, and then open the Query Editor, copy/paste the above script in the Query Editor, and execute it pressing F5.
Make a right click over "Database Snapshots", and select "Refresh", to see the newly created database snapshot.
Considerations for reverting to a Database Snapshot.
Procedure for reverting to a Database Snapshot.
1. Identify the database snapshot to which you want to revert the database using SQL Server Management Studio
2. Drop any other database snapshots.
3. Perform the revert operation. To revert the database, use the following Transact-SQL statement:
RESTORE DATABASE <database_name> FROM DATABASE_SNAPSHOT = <database_snapshot_name>
4. If the database owner changed since creation of the database snapshot, you may want to update the database owner of the reverted database.
5. Start the database.
6. Optionally, back up the reverted database, especially if it uses the full (or bulk-logged) recovery model.
Reverting to a Database Snapshot.
To revert the AdventureWorks database to the database snapshot we created before, use the following T-SQL command:
USE master;
-- Reverting AdventureWorks
-- to AWDB_Snapshot_20080522
RESTORE DATABASE AdventureWorks
FROM
DATABASE_SNAPSHOT = 'AWDB_Snapshot_20080522';
GO
References.
Database Snapshots
SQL Server 2008 Books Online (October 2007)
Database Mirroring and Database Snapshots
SQL Server 2008 Books Online (October 2007)
http://www.sqlcoffee.com/Tips0004.htm
http://technet.microsoft.com/en-us/library/ms189940%28v=sql.105%29.aspx
Introduction.
This article provides a summary of the information available on Microsoft SQL Server Books Online about Database Snapshots.
Definition.
A snapshot is read-only, static view of a database.
Useful scenarios.
When not to use database snapshots.
Some important considerations about database snapshots.
Planning for Database Snapshots.
Creating a Database Snapshot.
Here is a sample database snapshot create script on the AdventureWorks database.
CREATE DATABASE AWDB_Snapshot_20080522 ON (
NAME = AdventureWorks_Data,
FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\AWDB_Snapshot.ss')
AS SNAPSHOT OF AdventureWorks;
Open SQL Server Management Studio, and then open the Query Editor, copy/paste the above script in the Query Editor, and execute it pressing F5.
Make a right click over "Database Snapshots", and select "Refresh", to see the newly created database snapshot.
Considerations for reverting to a Database Snapshot.
Procedure for reverting to a Database Snapshot.
1. Identify the database snapshot to which you want to revert the database using SQL Server Management Studio
2. Drop any other database snapshots.
3. Perform the revert operation. To revert the database, use the following Transact-SQL statement:
RESTORE DATABASE <database_name> FROM DATABASE_SNAPSHOT = <database_snapshot_name>
4. If the database owner changed since creation of the database snapshot, you may want to update the database owner of the reverted database.
5. Start the database.
6. Optionally, back up the reverted database, especially if it uses the full (or bulk-logged) recovery model.
Reverting to a Database Snapshot.
To revert the AdventureWorks database to the database snapshot we created before, use the following T-SQL command:
USE master;
-- Reverting AdventureWorks
-- to AWDB_Snapshot_20080522
RESTORE DATABASE AdventureWorks
FROM
DATABASE_SNAPSHOT = 'AWDB_Snapshot_20080522';
GO
References.
Database Snapshots
SQL Server 2008 Books Online (October 2007)
Database Mirroring and Database Snapshots
SQL Server 2008 Books Online (October 2007)
http://www.sqlcoffee.com/Tips0004.htm
http://technet.microsoft.com/en-us/library/ms189940%28v=sql.105%29.aspx
No comments:
Post a Comment