Saves all logged updates for the specified database.

AS <UpdateName> TO STORE <StoreName>
[TABLES <TableName> [,<TableName>]]
[DESCRIPTION <Description>]
[COMPRESSION <Compression>]

<Compression> = 0..9

Use this statement to save the updates that have been logged for the specified tables to a single update file in the specified store. The store must have already been created using the CREATE STORE statement, and must be a local store.

The TABLES clause is optional and allows you specify a subset of tables from the database for saving. The default behavior is to save the logged updates for all tables in the database. All specified tables, either via the TABLES clause, or all of the tables in the database, must have been published already using the PUBLISH DATABASE statement, or you will receive an error.

Only the updates that have occurred since the last SAVE UPDATES execution will be saved. Once the SAVE UPDATES execution completes successfully, the logged updates are cleared from the specified tables, or all tables, if the TABLES clause is not specified.

The save process automatically uses special locking to ensure that none of the tables specified are updated until the process completes. This ensures a consistent snapshot of the logged updates for the specified tables.

The COMPRESSION clause allows you to specify the compression level (0..9). The default level of compression is 6.

Starting in 2.05, the IF NOT EMPTY clause can be used to specify that an update file should not be created if there aren't any updates present in any of the tables whose logged updates are being saved in the current operation. This is especially useful for situations where updates are being saved frequently.

Please see the Replication topic for more information on saving updates for a database.

-- This example saves the updates for the
-- Transaction table in the Accounting database

AS "AccountingDB-Updates-2007-03-12"
TO STORE TransactionUpdatesOut
TABLES Transaction

Required Privileges
The current user must be granted the MAINTAIN privilege on the current 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:

ExtensionThis SQL statement is an ElevateDB extension.