Icon RESTORE DATABASE

Restores the specified backup to a database.

Syntax
RESTORE DATABASE <Name>
FROM <BackupName>
IN STORE <StoreName>
[TABLES <TableName> [,<TableName>]]
[INCLUDE CATALOG [ONLY]]
[RESET PUBLISHED TABLES]

Usage
Use this statement to restore a backup from a specific store to a database.

The TABLES clause is optional and can be used to limit which tables will be restored from the backup. The default behavior is to restore all tables in the backup.

Information The TABLES clause only limits the table data that is restored. It doesn't prevent the table metadata from being restored. That is controlled by the INCLUDE CATALOG clause.

The INCLUDE CATALOG clause specifies that the database catalog should be restored in addition to the table data. It is recommended that you always include this clause. At the very least, you should restore the database with this clause whenever the catalog metadata in the backup doesn't match the existing catalog metadata in the database.

Warning Failure to include this clause in such a scenario would cause the restore to fail with an error.

You can use the ONLY clause to extend the INCLUDE CATALOG clause so that only the catalog is restored. This is dependent, of course, on the backup having the database catalog included during the BACKUP DATABASE statement that created the backup.

Information The ONLY clause can only be used if the TABLES clause is not present.

Starting in 2.05, the RESET PUBLISHED TABLES clause can be used to reset the publisher IDs for all published tables in the backup being restored. This is useful when you have backed up a database that includes published tables and do not want the target database to have the same publisher IDs. This is a common scenario when setting up a replicated database for the first time.

Information The RESET PUBLISHED TABLES clause can only be used in conjunction with the INCLUDE CATALOG clause.

Examples
-- This example restores the entire
-- Accounting database with the catalog included

RESTORE DATABASE Accounting
FROM "AccountingDB-DailyBackup-2006-03-12"
IN STORE "Backups"
INCLUDE CATALOG

Required Privileges
The current user must be granted the RESTORE privilege on the specified database in order to execute this statement. Please see the User Security topic for more information.

SQL 2003 Standard Deviations
This statement deviates from the SQL 2003 standard in the following ways:

DeviationDetails
ExtensionThis SQL statement is an ElevateDB extension.
Image