RDB/VMS Relational Database Operator DEFINE_DATABASE — VMS CDD+_4.1A
Creates a database file, specifies its name, and determines its
physical characteristics. This statement also creates a directory in
the data dictionary where definitions of other database elements can
be stored.
Example (single-file database):
RDO> DEFINE DATABASE 'PERSONNEL'.
Additional information available:
More
When the DEFINE DATABASE statement executes, Rdb/VMS:
o Creates a database file, a snapshot file, and, if the database is
multifile, storage area files.
o Creates a data dictionary entity for the database, including all
the system fields and relations, if the dictionary is installed.
o Assigns database parameters, and, if the database is multifile,
storage area parameters.
o Creates a default access control list.
o Invokes the newly created database, using the database file name
as the database handle.
You cannot issue the DEFINE DATABASE statement when a transaction is
active. It is best to make this the first statement of an RDO
session. Do not issue an INVOKE DATABASE statement after you use
DEFINE DATABASE. Rdb/VMS automatically invokes the database after
creating the database file.
Format
DEFINE DATABASE ─────> file-spec ───┬───────────>──────────┬───────┐ └─> invoke-options ────┘ │ │ ┌───────────────────────────<──────────────────────────────────────┘ │ └┬───────────>──────────┬────┬──────────────>───────────┬──────────┐ └──> db-wide-options ──┘ └─> storage-area-options ─┘ │ ┌─────────────────────────────<────────────────────────────────────┘ │ └┬┬──────────────>──────────────────────────────>───────────┬──────┬─> . │├─> define-storage-area-clause ────────────────>──────────┤ │ │└─>
S
E
G
M
E
N
T
E
D
S
T
R
I
N
G
S
T
O
R
A
G
E
A
R
E
A typebox (I)typebox (S) ─> storage-area-name ┘ │ │ │ └───────────────────────────────<─────────────────────────────────┘
Additional information available:
file-specinvoke-optionsdb-wide-optionsstorage-area-options
define-storage-area
file-spec
A file specification that names the database file. Put this file
specification in quotation marks. You should use either a full file
specification, including device, directory, and file name without the
file type, or a simple file name. In the second case, Rdb/VMS
creates the database in the current default directory. In a
single-file database, the file name specified becomes the file name
for two files:
o The database file. The default file type is RDB.
o The snapshot file. This file is used as a temporary file for
READ_ONLY transactions. The default file type is SNP.
In a multifile database, the file name specified becomes the file
name for three files:
o The database root file. The default file type is RDB.
o The default storage area file. The default file type is RDA.
o A snapshot file. The default file type is SNP.
invoke-options
invoke-options = ──┬───────────────────────────>──────────────────┬─────────────────> ├─────>
D
B
H
A
N
D
L
E typebox (I)typebox (S) ───────> db-handle ───────┤ └─────>
D
B
K
E
Y
S
C
O
P
E typebox (I)typebox (S) ──┬──>
C
O
M
M
I
T ───┬──────┘ └──>
F
I
N
I
S
H ───┘
Additional information available:
COMMIT
During the session of the user who entered DEFINE DATABASE, specifies that the database key of each record used is guaranteed not to change during each transaction this user may execute.
FINISH
During the session of this user who entered DEFINE DATABASE, specifies that the database key of each record used is guaranteed not to change until this user ends the RDO session or executes a FINISH statement.
db-wide-options
db-wide-options = ─┬─┬──────────────────────────>─────────────────────────────┬─┬──> │ ├─>
I
N ──────> path-name ────────────────────────────────┤ │ │ ├─>
D
E
S
C
R
I
P
T
I
O
N typebox (I)typebox (S) ───────> typebox (/)typebox (*) text */ ──────────────────┤ │ │ ├─>
N
U
M
B
E
R typebox (O)F
U
S
E
R
S typebox (I)typebox (S) ──> number-users ─────────────────┤ │ │ ├─>
N
U
M
B
E
R typebox (O)F
B
U
F
F
E
R
S typebox (I)typebox (S) ─────> number-buffers ──────────┤ │ │ ├─>
N
U
M
B
E
R typebox (O)F
V
A
X
C
L
U
S
T
E
R
N
O
D
E
S typebox (I)typebox (S) ──> number-nodes ──────┤ │ │ ├─>
N
U
M
B
E
R typebox (O)F
R
E
C
O
V
E
R
Y
B
U
F
F
E
R
S typebox (I)typebox (S) ───> recovery-buffers ─┤ │ │ ├─>
B
U
F
F
E
R
S
I
Z
E typebox (I)typebox (S) ─────> buffer-blocks ──>
B
L
O
C
K
S──────┤ │ │ ├─>
A
D
J
U
S
T
A
B
L
E
L
O
C
K
G
R
A
N
U
L
A
R
I
T
Y typebox (I)typebox (S) ─┬───>
E
N
A
B
L
E
D ───┬───┤ │ │ │ └───>
D
I
S
A
B
L
E
D ──┘ │ │ │ ├─>
S
N
A
P
S
H
O
T typebox (I)typebox (S) ────┬─────>
E
N
A
B
L
E
D ─┬─>
I
M
M
E
D
I
A
T
E──┬─┬─┤ │ │ │ │ └─>
D
E
F
E
R
R
E
D ──┘ │ │ │ │ │ └─────>
D
I
S
A
B
L
E
D ───────────>──────┘ │ │ │ └─>
D
I
C
T
I
O
N
A
R
Y typebox (I)typebox (S) ───┬───>
R
E
Q
U
I
R
E
D ───────┬─────────────┘ │ │ └───>
N
O
T
R
E
Q
U
I
R
E
D ───┘ │ └───────────────────────────────<────────────────────────────┘
Additional information available:
ENABLED-IMMEDIATEENABLED-DEFERREDDISABLEDDICTIONARY
ADJUSTABLE_LOCK
path-namenumber-buffersnumber-usersbuffer-blocksnumber-nodes
recovery-buffers
path-name
The data dictionary path name for the dictionary path name where the database definition is stored. Use this qualifier to store the data dictionary definitions for the database in a data dictionary entity other than the default path, which is defined by the name of the database file.
number-buffers
The number of buffers Rdb/VMS allocates per process using this database. Specify an unsigned integer greater than zero. The default is 20 buffers.
number-users
The maximum number of users allowed to access the database at one time. The default is 50 users.
buffer-blocks
The number of blocks Rdb/VMS allocates per buffer. Specify an unsigned integer greater than zero. If you do not specify this parameter, Rdb/VMS uses a buffer size that is three times the PAGE SIZE value.
ENABLED-IMMEDIATE
The default, ENABLED IMMEDIATE causes READ_WRITE transactions to write copies of records to the the snapshot file before those records are modified, regardless of whether a READ_ONLY transaction is active. If you use the SNAPSHOT IS ENABLED clause to enable snapshots on a multifile database, writing to all snapshot files for all storage areas is enabled.
ENABLED-DEFERRED
Specifies that READ_WRITE transactions not write copies of records they modify to the snapshot file unless a READ_ONLY transaction is active. READ_ONLY transactions that attempt to start after an active READ_WRITE transaction begins must wait for all active READ_WRITE users to complete their transactions. If you use the SNAPSHOT IS ENABLED clause to enable snapshots on a multifile database, writing to all snapshot files for all storage areas is enabled.
DISABLED
Disables snapshot transactions. If you use the SNAPSHOT IS DISABLED clause to disable snapshots on a multifile database, writing to all snapshot files for all storage areas is disabled.
number-nodes
Sets the upper limit on the maximum number of VAXcluster nodes from which users can access the shared database. The default is 16. The range is 1 to 64 nodes.
recovery-buffers
The number of database buffers used during the automatic recovery process that is initiated after a system or process failure. The default is 20 buffers.
DICTIONARY
Determines whether the database must be invoked by path name for data definition changes to occur. If you specify the DICTIONARY IS REQUIRED option, the database must be invoked by path name to change metadata and the data dictionary will be maintained. If you specify the DICTIONARY IS NOT REQUIRED option, the database can be invoked by either file name or path name to change metadata. The default is DICTIONARY IS NOT REQUIRED.
ADJUSTABLE_LOCK
Specifies whether adjustable locking granularity is enabled or disabled. The default is ENABLED.
storage-area-options
storage-area-options = ─┬┬──────────────────────────>─────────────────────────────────┬─┬──> │├─>
A
L
L
O
C
A
T
I
O
N typebox (I)typebox (S) ───> number-pages ────> ──────── typebox (P)typebox (A)typebox (G)typebox (E)typebox (S) ────┤ │ │├─>
P
A
G
E
S
I
Z
E typebox (I)typebox (S) ────> page-blocks ─────> ──────── typebox (B)typebox (L)typebox (O)typebox (C)typebox (K)typebox (S) ───┤ │ │├─>
P
A
G
E
F
O
R
M
A
T typebox (I)typebox (S) ──┬────>
U
N
I
F
O
R
M ────┬────────────────────┤ │ ││ └────>
M
I
X
E
D ──────┘ │ │ │├─>
T
H
R
E
S
H
O
L
D
S typebox (A)typebox (R)typebox (E) ─> (─> val1─┬─────────────────────┬───> )─┤ │ ││ └─> ,val2 ─┬────────┬─┘ │ │ ││ └>,val3 ─┘ │ │ │├─>
I
N
T
E
R
V
A
L typebox (I)typebox (S) ───────> number-data-pages ──────────────────┤ │ │├─>
E
X
T
E
N
T typebox (I)typebox (S) ────┬──> extent-pages ────> typebox (P)typebox (A)typebox (G)typebox (E)typebox (S) ───┬─────────┤ │ ││ └──> (extension-options)─────────┘ │ │ │├─>
S
N
A
P
S
H
O
T
F
I
L
E
N
A
M
E
I
S ────> file-spec ────────────────────┤ │ │├─>
S
N
A
P
S
H
O
T
A
L
L
O
C
A
T
I
O
N typebox (I)typebox (S) ───> snp-pages ───> typebox (P)typebox (A)typebox (G)typebox (E)typebox (S) ────────┤ │ │└─>
S
N
A
P
S
H
O
T
E
X
T
E
N
T typebox (I)typebox (S) ─┬─> extent-pages ────> typebox (P)typebox (A)typebox (G)typebox (E)typebox (S) ─┬──────┘ │ │ └─> (extension-options) ──────┘ │ └────────────<─────────────────────────────────────<────────────┘
Additional information available:
number-pagespage-blocksnumber-data-pagesfile-specsnp-pages
extent-pagesextension-options
number-pages
The number of database pages allocated to the database initially. Rdb/VMS automatically extends the allocation to handle the loading of data and subsequent expansion. The default is 400 pages.
page-blocks
The size in blocks of each database page. Page size is allocated in 512-byte blocks. The default is two blocks (1024 bytes). If your largest record is larger than approximately 950 bytes, allocate more blocks per page to prevent records from being fragmented.
PAGE_FORMAT
Specifies whether a storage area contains uniform or mixed pages. You can use the PAGE FORMAT option with multifile databases only. In storage areas with uniform page format, all pages in a specific logical area contain records from the same relation. In storage areas with mixed page format, pages can hold records from different relations. The default is UNIFORM.
THRESHOLDS
Specifies one, two, or three threshold values. The threshold values represent a fullness percentage on a data page and establish four possible ranges of guaranteed free space on the data pages. When a data page reaches the percentage defined by a given threshold value, the SPAM entry for the data page is updated to reflect the new fullness percentage and its remaining free space. The default thresholds are 70, 85, and 95 percent. When THRESHOLDS ARE is used, the first threshold value is required. If you specify only one or two values, unspecified values default to 100 percent. You can specify the THRESHOLDS option only on a storage area for a multifile database. The storage area page format must be MIXED.
number-data-pages
Specifies the number of data pages between SPAM pages in the physical storage area file, and thus the maximum of data pages each SPAM page will manage. The default, and also the minimum interval, is 256 data pages. The first page of each storage area is a SPAM page. The interval you specify determines where subsequent SPAM pages are to be inserted, provided there are enough data pages in the storage file to require more SPAM pages. You can specify the INTERVAL option only on a storage area for a multifile database. The storage area page format must be MIXED.
file-spec
Provides a separate file specification for the snapshot file. Do not specify a file extension other than SNP to the file specification. You cannot specify a global default for the SNAPSHOT FILENAME. Thus, in a multifile database, the SNAPSHOT FILENAME option must be within a DEFINE STORAGE AREA definition.
snp-pages
Specifies the number of pages allocated for the snapshot file. The default is 100 pages.
extent-pages
Specifies the number of pages of each extent. The default is 100 pages.
extension-options
Specifies the MIN, MAX, and percent growth of each database file extent. Enclose the parameter list in parentheses. extension-options = ───> ( ───>
M
I
N
I
M
U
M typebox (O)F ──> min-pages ───> typebox (P)typebox (A)typebox (G)typebox (E)typebox (S), ─┐ ┌────────────────────────────────────────┘ └──>
M
A
X
I
M
U
M typebox (O)F ──> max-pages ──> typebox (P)typebox (A)typebox (G)typebox (E)typebox (S),─┐ ┌────────────────────────────────────────┘ └──>
P
E
R
C
E
N
T
G
R
O
W
T
H typebox (I)typebox (S) ───> growth ────> ) ───>
Additional information available:
min-pages
Specifies the minimum number of pages of each extent. The default is 100 pages.
max-pages
Specifies the maximum number of pages of each extent. The default is 10,000 pages.
growth
Specifies the percent growth of each extent. The default is 20 percent growth.
define-storage-area
define-storage-area-clause = ────>
D
E
F
I
N
E
S
T
O
R
A
G
E
A
R
E
A ──┬────> storage-area-name ────┬──────┐ └────> typebox (R)typebox (D)typebox (B)typebox ($)typebox (S)typebox (Y)typebox (S)typebox (T)typebox (E)typebox (M) ───────────┘ │ ┌────────────────────────────────<──────────────────────────────┘ │ └─────>
F
I
L
E
N
A
M
E ─────> file-spec ──┬────────────>─────────────┬───┐ └─> storage-area-options ──┘ │ │ ┌──────────────────────────────────<───────────────────────────────┘ │ └──────────>
E
N
D ───┬─────────>───────────┬─> typebox (S)typebox (T)typebox (O)typebox (R)typebox (A)typebox (G)typebox (E) typebox (A)typebox (R)typebox (E)typebox (A) ────> ├─>storage-area-name ─┤ └─>typebox (R)typebox (D)typebox (B)typebox ($)typebox (S)typebox (Y)typebox (S)typebox (T)typebox (E)typebox (M) ────────┘
Additional information available:
storage-area-namestorage-area-options
storage-area-name
The name of the storage area you want to create.
RDB$SYSTEM
The default storage area. If you directly specify RDB$SYSTEM in the DEFINE STORAGE AREA clause, you can override the default characteristics for the main storage area.
storage-area-options
Ask for HELP on "DEFINE_DATABASE Format storage-area-options" for information on storage area options.
SEGMENTED_STRING
The name of the storage area that will hold all segmented strings. You can only specify the SEGMENTED STRING STORAGE AREA clause in a multifile database. In a multifile database, if you don't explicitly define a storage area for segmented strings, they will be stored in the default storage area (RDB$SYSTEM).
Examples
Example 1
Use the default DEFINE DATABASE Statement:
RDO> DEFINE DATABASE 'PERSONNEL'.
Example 2
Use DEFINE DATABASE with qualifiers:
RDO> DEFINE DATABASE 'PERSONNEL'
cont> NUMBER OF BUFFERS IS 10
cont> BUFFER SIZE IS 10 BLOCKS.
This statement performs the following actions:
o Names the database.
o Specifies a number of buffers, and the length of each buffer.
o Commits the database definition implicitly.
o Invokes the database, using the file name as the database handle.
Example 3
The scope of each record's database key is set to FINISH during the
RDO session of the user who entered DEFINE DATABASE:
RDO> DEFINE DATABASE DISK2:[USER.DBS]PERS2
cont> DBKEY SCOPE IS FINISH.
Note that this command does NOT set a "default" DBKEY SCOPE
characteristic for the database. For each user, the default is
COMMIT unless that user specifies INVOKE DATABASE...DBKEY SCOPE
FINISH.
Example 4
The upper limit on the number of VAXcluster nodes from which users
can access the common, cluster-wide database is set to 8:
RDO> DEFINE DATABASE ACCTING NUMBER VAXCLUSTER NODES IS 8.
If you attempt to access the shared database from a VAXcluster node
and, in doing so, exceed the maximum nodes parameter, an error is
signaled to your RDO session or program.
Example 5
The following example shows a part of the multifile MF_PERSONNEL
database definition. The example:
o Defines database wide characteristics
o Defines global storage area defaults
o Specifies local attributes for RDB$SYSTEM, the default storage
area
o Defines a storage area for segmented strings
o Defines other storage areas
This example includes only a few storage area definitions. The full
definition includes all of the storage area definitions.
DEFINE DATABASE 'DB_DISK:MULTI_PERS'
! Define database-wide characteristics
DESCRIPTION IS /* Sample multifile definition */
NUMBER OF USERS IS 60
NUMBER OF VAXCLUSTER NODES IS 22
DICTIONARY IS REQUIRED
NUMBER OF RECOVERY BUFFERS IS 200
! Define global storage area characteristics
ALLOCATION IS 500 PAGES
PAGE FORMAT IS MIXED
! Specify local attributes for the default storage area
! Override the global default of MIXED page format
DEFINE STORAGE AREA RDB$SYSTEM
FILENAME IS DISK1:PERS_DEFAULT
PAGE FORMAT IS UNIFORM
ALLOCATION IS 300 PAGES
SNAPSHOT_FILENAME IS DISK2:PERS_DEFAULT
END RDB$SYSTEM STORAGE AREA
! Define storage area for segmented strings
DEFINE STORAGE AREA PERS_SEGSTR
FILENAME IS DISK1:PERS_SEGSTR
PAGE FORMAT IS UNIFORM
END PERS_SEGSTR STORAGE AREA
SEGMENTED STRING STORAGE AREA IS PERS_SEGSTR
! Definition of some sample storage areas
DEFINE STORAGE AREA CANDIDATES
FILENAME IS DISK3:CANDIDATES
PAGE FORMAT IS UNIFORM
SNAPSHOT_FILENAME IS DISK4:CANDIDATES
END CANDIDATES STORAGE AREA
DEFINE STORAGE AREA EMPIDS_LOW
FILENAME IS DISK5:EMPIDS_LOW
SNAPSHOT_FILENAME IS DISK6:EMPIDS_LOW
END EMPIDS_LOW STORAGE AREA
DEFINE STORAGE AREA EMPIDS_MID
FILENAME IS DISK7:EMPIDS_MID
SNAPSHOT_FILENAME IS DISK8:EMPIDS_MID
END EMPIDS_MID STORAGE AREA.