EXPORT TABLE

Documentation

VoltDB Home » Documentation » Using VoltDB

EXPORT TABLE

EXPORT TABLE — Specifies that a table is for export only.

Synopsis

EXPORT TABLE table-name TO STREAM stream-name

Description

At runtime, any records written to an export-only table are queued to the appropriate export connector, as described in Chapter 15, Exporting Live Data. If export is enabled for this stream, the data is then passed to the export connector that manages the export process.

The stream-name specifies to which export stream the table belongs. You can enable and disable different export streams separately and export them to different destinations through configuration options in the deployment file.

The EXPORT TABLE statement lets you specify which tables in the schema are export-only tables. These tables become write-only. That is, they can be used in INSERT statements, but not SELECT, UPDATE, or DELETE statements.

If an export configuration is not specified or is not enabled for a particular stream at runtime, writing to export-only tables belonging to that stream has no effect.

Example

The following example defines two tables — User and User_Export — with similar columns. The second table is then defined as an export table. By inserting into the User_Export table every time a row is inserted into the User table, an automated list of users can be maintained external to the active VoltDB database.

CREATE TABLE User (
   UserID VARCHAR(15) NOT NULL,
   EmailAddress VARCHAR(128) NOT NULL,
   Created TIMESTAMP,
   Password VARCHAR(14),
   LastLogin TIMESTAMP);

CREATE TABLE User_Export (
   UserID BIGINT NOT NULL,
   EmailAddress VARCHAR(128) NOT NULL,
   Created TIMESTAMP);

EXPORT TABLE User_Export TO STREAM userarchive;