RESTORE DATABASE

From Lianjapedia
Jump to: navigation, search

Purpose

Restores a database backup

Syntax

RESTORE DATABASE <database name> [FROM <expC>]

See Also

ADATABASES(), ADD TABLE, ALTER INDEX, ALTER TABLE, BACKUP DATABASE, CHECK DATABASE, CHECK TABLE, CLOSE DATABASES, CLOSE TABLES, COMPARE DATABASE, COMPILE DATABASE, COPY DATABASE, CREATE DATABASE, CREATE INDEX, CREATE TABLE, CREATE VIEW, DATABASE(), DBUSED(), DISPLAY DATABASE, DISPLAY INDEXES, DISPLAY SCHEMAS, DISPLAY TABLES, DROP DATABASE, DROP INDEX, DROP TABLE, GETENV(), INDEX, LIST BACKUPS, LIST DATABASE, LIST INDEXES, LIST SCHEMAS, LIST TABLES, OPEN DATABASE, PACK, PACK DATABASE, REINDEX DATABASE, SET AUTOCATALOG, SET EXCLUSIVE, USE

Description

The RESTORE DATABASE command restores a previously created database backup for the database specified by <database name>. This is the equivalent of the 'Restore...' menu option from the Additional Commands or Context Menu in the Data Workspace.

Backups can be created using the BACKUP DATABASE command and are located under the backups sub-directory of the data directory by year, month, day and time. Available backups can be displayed using the LIST BACKUPS command.

The optional FROM <expC> clause can be used to restore a particular backup. The <expC> is a character string specifying the backup date and time as per the LIST BACKUPS command.

The <expC> can also be specified as '-N', where N is a number. In this case the backup N prior to the most recent backup is restored.

If the FROM <expC> clause is not included, the most recent available backup is restored.

The database should be closed when issuing the RESTORE DATABASE command.

Example

close databases
// Restore the most recent available backup
restore database southwind
// Restore the backup created before the most recent
restore database southwind from "-1"
// Restore the backup created two before the most recent
restore database southwind from "-2"
list backups
// Restore the backup from the specified date
restore database southwind from "2021-01-11 at 14:32:04"