SQL Guide : solidDB® SQL statements : EXPORT SUBSCRIPTION
  
EXPORT SUBSCRIPTION
EXPORT SUBSCRIPTION publication_name [(publication_parameters)]
   TO ’filename’
   USING BOOKMARK bookmark_name;
   [WITH [NO] DATA];
where
publication_name and bookmark_name are identifiers that must exist in the database.
filename represents a literal value enclosed in single quotation marks. You can export several publications to a single file by specifying the same file name.
WITH DATA option creates a replica with data, for example, when data is exported to an existing database that does not contain master data and requires a subset of data.
WITH NO DATA option creates a replica with only the metadata, for example, when a subscription is imported to a database that already contains the data (for example, using a backup copy of an existing master).
By default, the export file is created using the WITH DATA option and includes all rows. If there is more than one publication specified, the exported file can have a combination of WITH DATA and WITH NO DATA.
Usage
The EXPORT SUBSCRIPTION statement exports a version of data from a master database to a file. You can then use the IMPORT statement to import the data in the file into a replica database. The EXPORT SUBSCRIPTION statement is not available in a replica database.
There are several uses for the EXPORT SUBSCRIPTION statement. For example:
Create a large replica database (greater than 2 GB) from an existing master.
This procedure requires that you export a subscription with or without data to a file first, then import the subscription to the replica.
Export specific versions of the data to a replica.
For performance reasons, you could choose to export the data instead of using the MESSAGE APPEND REFRESH statement to send the data to a replica.
Export metadata information without the actual row data.
You could create a replica that already contains existing data and only needs the schema and version information associated with a publication.
Unlike the MESSAGE APPEND REFRESH statement where a REFRESH is requested from a replica, you request an export directly from the master database. The export output is saved to a user-specified file rather than a solidDB® message.
The EXPORT SUBSCRIPTION statement exports publication from the master database using REFRESH synchronization. If the publication uses input parameters, they are included in the REFRESH. The statement is based on a given bookmark, which means that export data is consistent up to this bookmark. When you export data, the EXPORT SUBSCRIPTION statement includes all rows as in a full publication up to the bookmark. However, since export is based on a given bookmark, the subsequent REFRESHes are incremental.
If a bookmark is created in a master for the purpose of exporting and importing data, the bookmark must exist when:
The EXPORT SUBSCRIPTION statement is executed on the master database.
If the bookmark does not exist at this point, error message 25067 is generated, indicating the bookmark cannot be found.
The IMPORT statement is executed on all intended replicas and replicas receive their first set of data ("REFRESH").
During a file import, a connection to a master database is not needed and the existence of the bookmark is not checked. However, if the bookmark does not exist at the time a replica receives its first REFRESH, the REFRESH fails with error message 25067 and the import data is unusable. The remedy is to create a new bookmark on the master, re-export the data, and re-import the data.
For more details, see “Exporting and importing subscriptionsin the solidDB® Advanced Replication User Guide.
Usage rules
The following rules apply to the EXPORT SUBSCRIPTION statement:
Only one file per subscription is allowed for export. You can use the same file name to include multiple subscriptions on the same file.
The file size of an export file depends on the underlying operating system. If the respective platform (such as SUN, or HP) allows more than 2 GB, you can write files greater than 2 GB. This means that replica (recipient) should also have a compatible platform and file system. Otherwise, the replica is not able to accept the export file. If both the operating system on a master and replica support file sizes greater than 2 GB, export files greater than 2 GB are permitted.
The export file can contain more than one subscription. Subscriptions can be exported using either the WITH DATA or WITH NO DATA options. An exported file with multiple subscriptions can have a combination of WITH DATA and WITH NO DATA included.
When a subscription is exported to a file using the WITH NO DATA option, only metadata (that is, schema and version information corresponding to that publication) is exported to the file.
Autocommit must be set off when using the EXPORT SUBSCRIPTION statement.
Return values
Error Code
Description
25056
Autocommit not allowed
25067
Bookmark is not found.
25068
Export file file_name open failure.
25010
Publication name not found.
Example
EXPORT SUBSCRIPTION FINANCE_PUBLICATION(2004) TO ’FINANCE.EXP’
USING BOOKMARK BOOKMARK_FOR_FINANCE_DB WITH NO DATA;
Related reference
CREATE [OR REPLACE] PUBLICATION
CREATE SYNC BOOKMARK
See also
solidDB® SQL statements