CREATE SHADOW

From InterBase

Go Up to Statement and Function Reference (Language Reference Guide)


Creates one or more duplicate, in-sync copies of a database. Available in gpre, DSQL, and isql.

CREATE SHADOW set_num [AUTO | MANUAL] [CONDITIONAL]
'<filespec>' [LENGTH [=] <int> [PAGE[S]]] 
[secondary_file];
secondary_file = FILE 'filespec' [fileinfo] [secondary_file]
fileinfo = LENGTH [=] int [PAGE[S]] | STARTING [AT [PAGE]] int

 [fileinfo]
Important:
In SQL statements passed to DSQL, omit the terminating semicolon. In embedded applications written in C and C++, and in isql, the semicolon is a terminating symbol for the statement, so it must be included.
Argument Description

<set_num>

Positive integer that designates a shadow set to which all subsequent files listed in the statement belong.

AUTO

Specifies the default access behavior for databases in the event no shadow is available.

  • All attachments and accesses succeed.
  • Deletes all references to the shadow and detaches the shadow file.

MANUAL

Specifies that database attachments and accesses fail until a shadow becomes available, or until all references to the shadow are removed from the database

CONDITIONAL

Creates a new shadow, allowing shadowing to continue if the primary shadow becomes unavailable or if the shadow replaces the database due to disk failure.

‘<filespec>’

Explicit path name and file name for the shadow file; must be a local file system and must not include a node name or be on a networked file system.

LENGTH[=] <int> [PAGE[S]]

Length in database pages of an additional shadow file; page size is determined by the page size of the database itself.

<secondary_file>

Specifies the length of a primary or secondary shadow file; use for primary file only if defining a secondary file in the same statement.

STARTING[AT[PAGE]] <int>

Starting page number at which a secondary shadow file begins.

Description: CREATE SHADOW is used to guard against loss of access to a database by establishing one or more copies of the database on secondary storage devices. Each copy of the database consists of one or more shadow files, referred to as a shadow set. Each shadow set is designated by a unique positive integer.

Disk shadowing has three components:

  • A database to shadow.
  • The RDB$FILES system table, which lists shadow files and other information about the database.
  • A shadow set, consisting of one or more shadow files.

When CREATE SHADOW is issued, a shadow is established for the database most recently attached by an application. A shadow set can consist of one or multiple files. In case of disk failure, the database administrator (DBA) activates the disk shadow so that it can take the place of the database. If CONDITIONAL is specified, then when the DBA activates the disk shadow to replace an actual database, a new shadow is established for the database.

If a database is larger than the space available for a shadow on one disk, use the <secondary_file> option to define multiple shadow files. Multiple shadow files can be spread over several disks.

Tip:
To add a secondary file to an existing disk shadow, drop the shadow with DROP SHADOW and use CREATE SHADOW to recreate it with the desired number of files.

Examples: The following isql statement creates a single, automatic shadow file for employee.ib:

CREATE SHADOW 1 AUTO 'employee.shd';

The next isql statement creates a conditional, single, automatic shadow file for employee.ib:

CREATE SHADOW 2 CONDITIONAL 'employee.shd' LENGTH 1000;

The following isql statements create a multiple-file shadow set for the ­employee.ib database. The first statement specifies starting pages for the shadow files; the second statement specifies the number of pages for the shadow files.

CREATE SHADOW 3 AUTO
'employee.sh1'
FILE 'employee.sh2'
STARTING AT PAGE 1000
FILE 'employee.sh3'
STARTING AT PAGE 2000;
CREATE SHADOW 4 MANUAL 'employee.sdw'
LENGTH 1000
FILE 'employee.sh1'
LENGTH 1000
FILE 'employee.sh2';

See Also

Advance To: