RDB/VMS SQL ALTER — VMS RDB_4.0B
Changes definitions for VAX SQL.
Additional information available:
DOMAININDEXSCHEMASTORAGE_MAPTABLE
DOMAIN
ALTER DOMAIN ────┐ ┌───────────────┘ └─>domain-name ┬─────────────────┬─┬─────────────────┬──┐ └─> typebox (I)typebox (S) data-type ─┘ └─>default-value ─┘ │ ┌───────────────────────────────────────────────────────┘ └─┬────────────────────────────────────────────┬──┐ ├───>
C
O
L
L
A
T
I
N
G
S
E
Q
U
E
N
C
E typebox (I)typebox (S) sequence-name ───┤ │ └───>
N
O
C
O
L
L
A
T
I
N
G
S
E
Q
U
E
N
C
E ─────────────────┘ │ ┌─────────────────────────────────────────┘ └──┬──────────────────────────┬──> typebox (;) └┬─> sql-and-dtr-clause ──┬┘ └───────<────────────────┘
Additional information available:
COLLATING_SEQUENCE_ISNO_COLLATING_SEQUENCE
More Informationdefault valuesql and dtr clause
More Information
Alters a domain definition. This allows you to change the data type, optional default value, collating sequence, or SQL and DATATRIEVE formatting parameters for all columns defined using the domain, simply by changing the domain itself. For example, if you want to change the data type for EMPLOYEE_ID from CHAR(5) to CHAR(6), you need only alter the data type for ID_DOM. You do not have to alter the data type for the column EMPLOYEE_ID in the tables DEGREES, EMPLOYEES, JOB_HISTORY, SALARY_HISTORY, nor do you have to alter the column MANAGER_ID in DEPARTMENTS. You can alter any named domain once you have declared the schema that includes the domain. If you want to alter a domain that is referred to in an index definition, you must first drop the index. If a domain definition is stored in the data dictionary, the ALTER DOMAIN statement alters the domain definition in the data dictionary.
default value
default-value = DEFAULT ──┬──>literal ─┬───> ├──>
U
S
E
R ───┤ └──>
N
U
L
L ───┘
Additional information available:
literal
A value expression that is either numeric, character string, or date.
USER
The user name of the process that invokes interactive SQL or runs a program.
NULL
A null value.
CURRENT_TIMESTAMP
The date and time currently defined in Rdb/VMS.
More information
The default value of a column is the value stored in the database if an insert operation on a row specifies no value for that column. You can use literals, the NULL keyword, the current timestamp, or the user name as default values. If you do not specify a default value, SQL assigns NULL as the default value. If you specify a default value for a column in a table, it overrides any default value specified for the domain on which the column is based. You might have any of several possible reasons for specifying a default value for a column; for instance, you may want to store the most commonly used value, or you may want to store a value that highlights (is visual displays) the fact that no value was stored.
COLLATING_SEQUENCE_IS
Specifies a new collating sequence for the named domain. The VMS National Character Set (NCS) Utility provides a set of pre-defined collating sequences and also lets you define collating sequences of your own. The COLLATING SEQUENCE clause accepts both pre-defined and user-defined NCS collating sequences. Before you use the COLLATING SEQUENCE clause in an ALTER DOMAIN statement, you must first specify the NCS collating sequence for SQL using the CREATE COLLATING SEQUENCE statement. The sequence-name argument in the COLLATING SEQUENCE clause must be the same as the sequence-name in the CREATE COLLATING SEQUENCE statement
NO_COLLATING_SEQUENCE
Specifies that the named domain will use the standard default collating sequence: that is, ASCII. Use the NO COLLATING SEQUENCE clause to override the collating sequence defined for the schema in the CREATE SCHEMA or ALTER SCHEMA statement, or the domain in the CREATE DOMAIN statement.
sql and dtr clause
sql-and-dtr-clause = ─┬─>
Q
U
E
R
Y
H
E
A
D
E
R typebox (I)typebox (S) ─┬> quoted-string ──┬─────────────────┬─> │ └────── typebox (/) <────────┘ │ ├─>
E
D
I
T
S
T
R
I
N
G typebox (I)typebox (S) quoted-string ─────────────────────────┤ │ │ ├─>
Q
U
E
R
Y
N
A
M
E Ftypebox (O)typebox (R) ─┬─> typebox (D)typebox (T)typebox (R) ────────┬─> typebox (I)typebox (S) quoted-string ─┤ │ └─> typebox (D)typebox (A)typebox (T)typebox (A)typebox (T)typebox (R)typebox (I)typebox (E)typebox (V)typebox (E) ─┘ │ ├─>
D
E
F
A
U
L
T
V
A
L
U
E Ftypebox (O)typebox (R) ─┬─> typebox (D)typebox (T)typebox (R) ────────┬─> typebox (I)typebox (S) literal ────┤ │ └─> typebox (D)typebox (A)typebox (T)typebox (A)typebox (T)typebox (R)typebox (I)typebox (E)typebox (V)typebox (E) ─┘ │ ├─>
N
O
Q
U
E
R
Y
H
E
A
D
E
R ──────────────────────────────────────┤ ├─>
N
O
E
D
I
T
S
T
R
I
N
G ───────────────────────────────────────┤ ├─>
N
O
Q
U
E
R
Y
N
A
M
E ────┬──> Ftypebox (O)typebox (R) ─┬─> typebox (D)typebox (T)typebox (R) ────────┬─────────┘ └─>
N
O
D
E
F
A
U
L
T
V
A
L
U
E ─┘ └─> typebox (D)typebox (A)typebox (T)typebox (A)typebox (T)typebox (R)typebox (I)typebox (E)typebox (V)typebox (E) ─┘ Optional formatting clauses allow you to modify data displays or query characteristics for interactive SQL users and DATATRIEVE users. A query header specifies a string that interactive SQL or DATATRIEVE displays in place of the column name when it retrieves values from a column. An edit string specifies a string that controls how interactive SQL or DATATRIEVE formats the display of values in a column. DEFAULT VALUE and QUERY NAME are active only from DATATRIEVE.
INDEX
ALTER INDEX index-name ─┐ ┌───────────────────────┘ └─┬────────────────────────────────┬─┬───────────────────────┬─> typebox (;) └┬┬─>
N
O
D
E
S
I
Z
E number-bytes ──┬┬┘ └─> index-store-clause ─┘ │├─>
P
E
R
C
E
N
T
F
I
L
L percentage ─┤│ │└─>
U
S
A
G
E ─┬─>
U
P
D
A
T
E ─┬─────┘│ │ └─>
Q
U
E
R
Y ──┘ │ └────────────────<─────────────┘
Additional information available:
More Informationindex store clause
More Information
Changes an index. The ALTER INDEX statement allows you to change:
o The characteristics of index nodes (sorted indexes only)
o The names of the storage area or storage areas that contain the
index
You cannot change:
o The columns that comprise an index
o Whether the index is UNIQUE
o A hashed to a sorted index
o A sorted index to a hashed index
You cannot alter an index when there are other active users of the
database.
index store clause
index-store-clause = STORE ─┐ ┌───────────────────────────┘ ├─>
I
N area-name ─────────────────────────────────────────────────┬─> └─>
U
S
I
N
G ─> ( ─┬─> column-name ─┬─> ) ─┐ │ └────── , <──────┘ │ │ ┌──────────────────────────────────────┘ │ └┬─>
I
N area-name WITH LIMIT OF ─> ( ─┬─ literal ─┬─> ) ─┬─┐ │ │ └──── , <───┘ │ │ │ └────────────────────────── <───────────────────────────┘ │ │ ┌──────────────────────────────────────────────────────────┘ │ └─>
O
T
H
E
R
W
I
S
E typebox (I)typebox (N) area-name ──────────────────────────────────────┘
Additional information available:
More Information
A storage map definition for the index. You can specify a store
clause for indexes in a multifile schema only. The STORE clause in a
CREATE INDEX statement allows you to specify which storage area files
will be used to store the index entries:
o All index entries can be associated with a single storage area.
o Index entries can be systematically distributed, or partitioned,
among several storage areas by specifying upper limits on the
values for a key in a particular storage area.
If you omit the storage map definition, the default is to store all
the entries for an index in the main RDB$SYSTEM storage area.
You should define a storage area for an index that matches the
storage map for the table with which it is associated.
SCHEMA
ALTER SCHEMA ─┬─>
P
A
T
H
N
A
M
E path-name ─┬──┐ └─>
F
I
L
E
N
A
M
E file-spec ─┘ │ ┌────────────────────<───────────────────┘ └─┬─────────────>──────────────┬─┬──────────────>─────────────┬─┐ └─> alter-root-file-params1 ─┘ └─> alter-root-file-params2 ─┘ │ ┌───────────────────────────────────────────────────────────────┘ └─┬──────────────>────────────────┬──┐ └─> alter-storage-area-params ──┘ │ ┌────────────────<───────────────────┘ └─┬┬───────────────────────────>───────────────────────────────┬┬─> typebox (;) │├─>
A
D
D
S
T
O
R
A
G
E
A
R
E
A area-name ─┬───────────> ──────────┬─┐ ││ ││ └─>
F
I
L
E
N
A
M
E file-spec ─┘ │ ││ ││ ┌─────────────────────── <────────────────────────────┘ ││ ││ └─> storage-area-params ────────────────────────────────┤│ │├─>
A
L
T
E
R
S
T
O
R
A
G
E
A
R
E
A area-name alter-storage-area-params ─┤│ │└─>
D
R
O
P
S
T
O
R
A
G
E
A
R
E
A area-name ────────────────────────────┘│ └──────────────────────────────<──────────────────────────────┘
Additional information available:
ADD_STORAGE_AREAALTER_STORAGE_AREADROP_STORAGE_AREA
alter root file params1alter root file params2alter storage area paramsMore Information
storage area params
ADD_STORAGE_AREA
Specifies the name and file specification for a storage area you want to add to the schema. You can use the ADD STORAGE AREA clause only on multifile databases. The area name cannot be the same as any other storage area definition in the schema. The ADD STORAGE AREA clause creates two files, a data file with a file extension of .RDS and a snapshot file with a file extension of .SNP. If you omit the FILENAME argument, the file specification takes the following defaults: o Device: the current device for the process o Directory: the current device for the process o File name: the name specified for the storage area The file specification is used for both the data and snapshot files that comprise the storage area (unless you use the SNAPSHOT FILENAME argument to specify a different file for the snapshot file). Because the ADD STORAGE AREA clause may create two files with different file extensions, do not specify a file extension with the file specification.
ALTER_STORAGE_AREA
Specifies the name of an existing storage area in the schema that you want to alter. You can use the ALTER STORAGE AREA clause only on multifile databases. The alter-storage-area-params are parameters that the ALTER STORAGE AREA clause changes.
alter root file params1
alter-root-file-params1 = ─┬─┬─┬─>
O
P
E
N typebox (I)typebox (S) ────────────┬──>
A
U
T
O
M
A
T
I
C ─┬───────────────┬─┬─┬─> │ │ │ └──>
M
A
N
U
A
L ─────┘ │ │ │ │ │ ├─>
R
E
A
D
W
R
I
T
E ──────────────────────────────────────────┤ │ │ │ │ ├─>
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) ──> number-buffers ────┤ │ │ │ │ └─>
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 ────────>────────┘ │ │ │ └────────────────────────────<───────────────────────────────┘ │ └─────>
R
E
A
D
O
N
L
Y ─────────────>─────────────────────────────────┘
Additional information available:
More Information
Parameters that control the characteristics of the database root file associated with the schema, or characteristics stored in the root file that apply to the entire database. You can specify these parameters for either single-file or multifile databases. Note that ALTER SCHEMA does not allow you to change all root file parameters you can specify in CREATE SCHEMA. You must use the EXPORT and IMPORT statements to change the following root file parameters: o BUFFER SIZE o NUMBER OF USERS (for a single-file database) o NUMBER OF VAXCLUSTER NODES (for a single-file database) o SEGMENTED STRING STORAGE AREA o PROTECTION IS ANSI PROTECTION IS ACL
READ_ONLY
Use the READ ONLY option to change a read/write RDB$SYSTEM storage area (and the Rdb/VMS system relations stored in the area) to read-only. You might choose the READ ONLY option if your database is never or rarely updated. When the RDB$SYSTEM storage area is changed to read-only, locking conflicts occur less frequently, and the automatic updating of index and relation cardinality is inhibited. For information on changing a read/write storage area other than the RDB$SYSTEM storage area to read-only, see the "READ_ONLY" subtopic for "alter_storage_area_params".
READ_WRITE
Use the READ WRITE option to change a read-only RDB$SYSTEM storage area (and the Rdb/VMS system relations stored in the area) to read/write. For information on changing a read/only storage area other than the RDB$SYSTEM storage area to read/write, see the "READ_WRITE" subtopic for "alter_storage_area_params".
alter root file params2
alter-root-file-params2 = ───┬─┬─>
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 ───┘ │ │ │ ├─>
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 ─┘ │ │ │ ├─>
J
O
U
R
N
A
L
F
I
L
E
N
A
M
E file-spec ──────────────────────────┤ │ │ ├─>
J
O
U
R
N
A
L
A
L
L
O
C
A
T
I
O
N typebox (I)typebox (S) ─> journal-blocks ─> typebox (B)typebox (L)typebox (O)typebox (C)typebox (K)typebox (S) ───┤ │ │ ├─>
J
O
U
R
N
A
L
E
X
T
E
N
T typebox (I)typebox (S) ───> extent-blocks ──> typebox (B)typebox (L)typebox (O)typebox (C)typebox (K)typebox (S) ─────┤ │ │ └─>
N
O
J
O
U
R
N
A
L ──────────────────────────────────────────┘ │ └──────────────────────────────<─────────────────────────────┘
Additional information available:
More Information
Parameters that control the characteristics of the database root file associated with the schema, or characteristics stored in the root file that apply to the entire database. You can specify these parameters for either single-file or multifile databases. Note that ALTER SCHEMA does not allow you to change all root file parameters you can specify in CREATE SCHEMA. You must use the EXPORT and IMPORT statements to change the following root file parameters: o BUFFER SIZE o NUMBER OF USERS (for a single-file database) o NUMBER OF VAXCLUSTER NODES (for a single-file database) o SEGMENTED STRING STORAGE AREA o PROTECTION IS ANSI PROTECTION IS ACL
alter storage area params
alter-storage-area-params = ─┬─┬─┬─>
R
E
A
D
W
R
I
T
E ─────────────────────────────────────┬─┬─┬─> │ │ ├─>
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
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) ───┘ │ │ │ └─────────────────────────────<─────────────────────────┘ │ └─────>
R
E
A
D
O
N
L
Y ──────────────────────────────────────────┘
Additional information available:
More Informationextension options
More Information
Parameters that change the characteristics of database storage area
files. You can specify the same storage area parameters for either
single-file or multifile databases, but the effect of the clauses in
this part of an ALTER SCHEMA statement differs:
o For single-file databases, the storage area parameters change the
characteristics for the single storage area in the schema
o For multifile databases, the storage area parameters change the
characteristics of the RDB$SYSTEM storage area. SQL generates an
error if you specify RDB$SYSTEM as the area name in the ALTER
STORAGE AREA clause, so specifying the parameters in this part of
the ALTER SCHEMA statement is the only way to change the
parameters of the RDB$SYSTEM storage area using ALTER SCHEMA.
Note that ALTER SCHEMA does not allow you to change all storage area
parameters you can specify in CREATE SCHEMA. You must use the EXPORT
and IMPORT statements to change the following root file parameters:
o ALLOCATION
o PAGE SIZE
o PAGE FORMAT
o THRESHOLDS
o INTERVAL
o SNAPSHOT FILENAME
READ_ONLY
Permits you to change any read/write storage area (except the RDB$SYSTEM storage area) to read-only. For information on changing a read/write RDB$SYSTEM storage area to read-only, see the "READ_ONLY" subtopic for "alter_root_file_params1".
Additional information available:
More Information
SQL provides support for both read-only databases and databases with
one or more read-only storage areas. You can take advantage of this
read-only support if you have a stable body of data that is never (or
rarely) updated.
Read-only databases consist of:
o A read/write root file
o One or more read-only storage areas and no read/write storage
areas
Read-only databases can be published and distributed on CDROM media.
Read-only storage areas:
o Do not have snapshot files (since data in a read-only storage
area is not updated)
o Minimize locking problems in the read-only storage areas
o Are not backed up by RMU/BACKUP unless explicitly instructed
(thus decreasing backup time for large areas of data that do not
change)
o Are not restored by RMU/RESTORE unless explicitly instructed
o Are not recovered by RMU/RECOVER
If you change a read/write storage area to read-only, you cannot
specify the EXTENT, SNAPSHOT ALLOCATION, and SNAPSHOT EXTENT clauses.
A database with both read/write and read-only storage areas can be
fully recovered after a system failure ONLY if after-image journaling
is enabled on the database. If your database has both read/write and
read-only storage areas but does not have after-image journaling
enabled, you should do full backups (including read-only areas) at
all times. Doing full backups enables you to recover the entire
database to its condition at the time of the previous backup.
You must convert and remaster read-only storage areas with each
upgrade of Rdb/VMS.
READ_WRITE
Permits you to change any read-only storage area (except the RDB$SYSTEM storage area) to read/write. You might change a read-only storage area to read/write to facilitate batch updates to infrequently changed data. For information on changing a read-only RDB$SYSTEM storage area to read/write, see the "READ_WRITE" subtopic for "alter_root_file_params1".
extension options
extension-options = ──>
M
I
N
I
M
U
M typebox (O)F min-pages PAGES, ─┐ ┌────────────────────────────────┘ └─>
M
A
X
I
M
U
M typebox (O)F max-pages PAGES, ┐ ┌───────────────────────────────┘ └─>
P
E
R
C
E
N
T
G
R
O
W
T
H typebox (I)typebox (S) growth ──> Changes the number of pages of each snapshot or storage area file extent.
DROP_STORAGE_AREA
Deletes the specified storage area definition and the associated data and snapshot files. You can use the DROP STORAGE AREA clause only on multifile databases. To protect against accidental data deletion, the ALTER SCHEMA statement fails if you specify a DROP STORAGE AREA clause that names a storage area referred to in any storage map. You must first use the ALTER STORAGE MAP statement to move the data to another storage area.
More Information
Alters a schema in any of the following ways:
o For both single-file and multifile databases, changes
characteristics of the database root file associated with a
schema. ALTER SCHEMA allows you to override certain
characteristics specified in the root file parameters of a CREATE
SCHEMA statement, such as whether a snapshot file is disabled.
In addition, ALTER SCHEMA lets you control other characteristics
you cannot specify in CREATE SCHEMA root file parameters, such as
whether after-image journaling is enabled.
o For both single-file and multifile databases, changes storage
area parameters.
o For multifile databases only, adds, alters, or drops storage
areas.
storage area params
storage-area-params = ─┬─┬──────────────────────────>─────────────────────────────┬─┬──> │ ├─>
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 ───> 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) ────┘ │ └────────────────────────────<───────────────────────────────┘ Parameters that control the characteristics of the storage area.
STORAGE_MAP
ALTER STORAGE MAP map-name ─┐ ┌───────────────────────────┘ └──┬───┬─> store-clause ─────────────────────┬─┬──┬─>typebox (;) │ ├─>
N
O
P
L
A
C
E
M
E
N
T
V
I
A
I
N
D
E
X ───────────┤ │ │ │ ├─>
P
L
A
C
E
M
E
N
T
V
I
A
I
N
D
E
X index-name ───┤ │ │ │ ├─┬─>
E
N
A
B
L
E ──┬─>
C
O
M
P
R
E
S
S
I
O
N ───────┘ │ │ │ │ └─>
D
I
S
A
B
L
E ─┘ │ │ │ └─>
R
E
O
R
G
A
N
I
Z
E ──> ──┬────>──────┬──────┘ │ │ ├─>
A
R
E
A
S ──┤ │ │ └─>
P
A
G
E
S ──┘ │ └──────────────────────<───────────────────────┘
Additional information available:
More Information
Changes an existing storage map. A storage map controls which rows
of a table are stored in which storage areas in a multifile database.
In addition to changing storage maps, ALTER STORAGE MAP has options
that change:
o Which index the database system uses when inserting rows in the
table
o Whether the rows of the table will be stored in a compressed
format
o Whether the data in the existing storage areas will be
reorganized
store clause
store-clause = STORE ─┐ ┌─────────────────────┘ ├─>
I
N area-name ─────────────────────────────────────────────────┬─> ├─>
A
C
R
O
S
S ─> ( ─┬─> area-name ─┬─> ) ────────────────────────────┤ │ └───── , <─────┘ │ └─>
U
S
I
N
G ─> ( ─┬─> column-name ─┬─> ) ─┐ │ └────── , <──────┘ │ │ ┌──────────────────────────────────────┘ │ └┬─>
I
N area-name WITH LIMIT OF ─> ( ─┬─ literal ─┬─> ) ─┬─┐ │ │ └──── , <───┘ │ │ │ └────────────────────────── <───────────────────────────┘ │ │ ┌──────────────────────────────────────────────────────────┘ │ └─>
O
T
H
E
R
W
I
S
E typebox (I)typebox (N) area-name ──────────────────────────────────────┘
Additional information available:
More Information
A new storage map definition that replaces the existing storage map.
The store clause allows you to specify which storage area files will
be used to store rows from the table:
o All rows of a table can be associated with a single storage area.
o Rows of a table can be distributed among several storage areas.
o Rows of a table can be systematically distributed, or
partitioned, among several storage areas by specifying upper
limits on the values for a column in a particular storage area.
TABLE
ALTER TABLE ──> table-name ──┐ ┌────────────────────────────┘ └─┬─┬─>
A
D
D ─┬─> typebox (C)typebox (O)typebox (L)typebox (U)typebox (M)typebox (N) add-col-definition ─────────┬──> typebox (;) │ │ └─>
C
O
N
S
T
R
A
I
N
T table-constraint ───────┤ │ ├─>
A
L
T
E
R alter-col-definition ─────────────────┤ │ └─>
D
R
O
P ─┬─> typebox (C)typebox (O)typebox (L)typebox (U)typebox (M)typebox (N) column-name ───────────────┤ │ └─>
C
O
N
S
T
R
A
I
N
T constraint-name ───────┤ └──────────────────── <───────────────────────────┘
Additional information available:
ADD_COLUMNADD_CONSTRAINTALTER_COLUMNDROP_COLUMN
DROP_CONSTRAINT
More Information
The ALTER TABLE statement changes an existing table definition. You can: o Add columns o Add constraints to tables or columns o Modify columns o Delete columns o Delete constraints
ADD_COLUMN
The ADD COLUMN clause creates an additional column in the table. SQL
adds the column to the right of the existing columns in the table.
add-col-definition =
─>column-name ──┬─> data-type ───┬──┬───────────────────┬─┐
└─> domain-name ─┘ └─> default value ──┘ │
┌─────────────────────────────────────────────────────────┘
└──┬──────────────────┬─┬───────────────────────┬─>
└─> col-constraint─┘ ├─> sql-and-dtr-clause ─┤
└────────────<──────────┘
Specify a name for the column, a data type or domain name, and
optional default value, column-constraints, and SQL and DATATRIEVE
formatting clauses for the column specified by the column name.
Additional information available:
data typedefault valuecol constraintsql and dtr clause
data type
data-type = ──┬─>
C
H
A
R ─┬────────┬───────────────────────────┬──> │ └─> (n) ─┘ │ ├─>
V
A
R
C
H
A
R (n) ───────────────────────────────┤ ├─>
L
O
N
G
V
A
R
C
H
A
R ──────────────────────────────┤ ├─>
T
I
N
Y
I
N
T ──────────────┬─────┬────────┬─────┤ ├─>
S
M
A
L
L
I
N
T ─────────────┤ └─> (n) ─┘ │ ├─>
I
N
T
E
G
E
R ──────────────┤ │ ├─>
Q
U
A
D
W
O
R
D ─────────────┤ │ ├─>
L
I
S
T
O
F
B
Y
T
E
V
A
R
Y
I
N
G ─┘ │ ├─>
D
E
C
I
M
A
L ─┬─┬─────────────────────────────┬─┤ ├─>
N
U
M
E
R
I
C ─┘ └─> ( ──> n ─┬────────┬─> ) ──┘ │ │ └─> , n ─┘ │ ├─>
F
L
O
A
T ─┬────────┬──────────────────────────┤ │ └─> (n) ─┘ │ ├─>
R
E
A
L ──────────────────────────────────────┤ ├─>
D
O
U
B
L
E
P
R
E
C
I
S
I
O
N ──────────────────────────┤ └─>
D
A
T
E ──────────────────────────────────────┘
default value
default-value = DEFAULT ──┬──>literal ─┬───> ├──>
U
S
E
R ───┤ └──>
N
U
L
L ───┘
Additional information available:
More informationliteralMore Information
More information
The default value of a column is the value stored in the database if an insert operation on a row specifies no value for that column. You can use literals, the NULL keyword, the current timestamp, or the user name as default values. If you do not specify a default value, SQL assigns NULL as the default value. If you specify a default value for a column in a table, it overrides any default value specified for the domain on which the column is based. You might have any of several possible reasons for specifying a default value for a column; for instance, you may want to store the most commonly used value, or you may want to store a value that highlights (is visual displays) the fact that no value was stored.
literal
A value expression that is either numeric, character string, or date.
USER
The user name of the process that invokes interactive SQL or runs a program.
NULL
A null value.
CURRENT_TIMESTAMP
The date and time currently defined in Rdb/VMS.
More Information
A value to be stored in a column if the row that is inserted does not include a value for that column. You can use literals, the NULL keyword, the current timestamp, or the user name as default values. If you do not specify a default value, a column inherits any default value from the domain. If you do not specify a default value for either the column or domain, SQL assigns NULL as the default value.
col constraint
col-constraint = ─┬─>
P
R
I
M
A
R
Y
K
E
Y ──────────────────────┬──┐ ├─>
N
O
T
N
U
L
L ─────────────────────────┤ │ ├─>
U
N
I
Q
U
E ───────────────────────────┤ │ ├─>
C
H
E
C
K (predicate) ────────────────┤ │ └─> references-clause ────────────────┘ │ ┌───────────────────────<────────────────┘ └─┬─────────────────>─────────────┬─> └─>
C
O
N
S
T
R
A
I
N
T constraint-name ─┘
Additional information available:
More Informationreferences clause
More Information
A col-constraint is a constraint definition that applies to the
specified column. The five types of column constraints are PRIMARY
KEY, NOT NULL, UNIQUE, CHECK, and foreign key constraints. Foreign
key constraints are created with the REFERENCES clause. You can also
optionally specify a name for a constraint definition.
The PRIMARY KEY column constraint declares a column to be a primary
key. SQL requires that values in this column be unique and not null.
Therefore, you need not specify the UNIQUE and NOT NULL column
constraints for a primary key column.
The NOT NULL column constraint restricts values in the column to
non-null values.
The UNIQUE column constraint specifies that values in the column
named must be unique. You can use either UNIQUE or PRIMARY KEY
keywords to define a column as a unique key for a table.
The CHECK column constraint specifies a predicate that column values
inserted into the table must satisfy. Predicates in CHECK table
constraints can refer directly only to the column with which they are
associated.
The optional CONSTRAINT constraint-name specifies a name for a column
constraint that is used in several ways:
o The INTEG_FAIL error message specifies the name when an INSERT,
UDPATE, or DELETE statement violates the constraint
o ALTER TABLE DROP CONSTRAINT statements specify the name to drop a
table constraint
o SHOW TABLE statements display the names of column and table
constraints
The name of the constraint is used in error messages and ALTER TABLE
DROP CONSTRAINT, SHOW TABLE, DECLARE TRANSACTION and SET TRANSACTION
statements. The CONSTRAINT clause is optional. If you omit the
constraint name, SQL creates a name. However, DIGITAL recommends
that you always name column and table constraints. The constraint
names generated by SQL may be obscure and, in programs, may change
between compilation and running.
references clause
references-clause =
REFERENCES referenced-table-name ───┐
┌─────────────────<────────────────┘
└─┬─────────────────────>───────────────────┬─>
└─> ( ─┬─> referenced-column-name ─┬─> ) ─┘
└─────────── , <────────────┘
Specifies the name of a column or columns that are a unique key or
primary key in the referenced table. When the REFERENCES clause is
selected as a column-constraint, the column specified in the
col-definition clause becomes a foreign key for the referencing table
(the table being defined). When the REFERENCES clause is selected as
a table constraint, the column name or column names specified in the
FOREIGN KEY clause become a foreign key for the referencing table.
The referenced_table_name is the name of the table that contains the
unique key or primary key referenced by the referencing table. You
must have the SQL access right REFERENCES or CREATETAB to the
referenced table.
For a column constraint, the referenced_column_name is the name of
the column that is a unique key or primary key in the referenced
table. For a table constraint, the the referenced_column_name is the
name of the column or columns that are a unique key or primary key in
the referenced table. The unique key can be defined with either the
UNIQUE or PRIMARY KEY keywords. If you omit the
referenced_column_name, the primary key is selected by default.
sql and dtr clause
sql-and-dtr-clause = ─┬─>
Q
U
E
R
Y
H
E
A
D
E
R typebox (I)typebox (S) ─┬> quoted-string ──┬─────────────────┬─> │ └────── typebox (/) <────────┘ │ ├─>
E
D
I
T
S
T
R
I
N
G typebox (I)typebox (S) quoted-string ─────────────────────────┤ │ │ ├─>
Q
U
E
R
Y
N
A
M
E Ftypebox (O)typebox (R) ─┬─> typebox (D)typebox (T)typebox (R) ────────┬─> typebox (I)typebox (S) quoted-string ─┤ │ └─> typebox (D)typebox (A)typebox (T)typebox (A)typebox (T)typebox (R)typebox (I)typebox (E)typebox (V)typebox (E) ─┘ │ ├─>
D
E
F
A
U
L
T
V
A
L
U
E Ftypebox (O)typebox (R) ─┬─> typebox (D)typebox (T)typebox (R) ────────┬─> typebox (I)typebox (S) literal ────┤ │ └─> typebox (D)typebox (A)typebox (T)typebox (A)typebox (T)typebox (R)typebox (I)typebox (E)typebox (V)typebox (E) ─┘ │ ├─>
N
O
Q
U
E
R
Y
H
E
A
D
E
R ──────────────────────────────────────┤ ├─>
N
O
E
D
I
T
S
T
R
I
N
G ───────────────────────────────────────┤ ├─>
N
O
Q
U
E
R
Y
N
A
M
E ────┬──> Ftypebox (O)typebox (R) ─┬─> typebox (D)typebox (T)typebox (R) ────────┬─────────┘ └─>
N
O
D
E
F
A
U
L
T
V
A
L
U
E ─┘ └─> typebox (D)typebox (A)typebox (T)typebox (A)typebox (T)typebox (R)typebox (I)typebox (E)typebox (V)typebox (E) ─┘ Optional formatting clauses allow you to modify data displays or query characteristics for interactive SQL users and DATATRIEVE users. A query header specifies a string that interactive SQL or DATATRIEVE displays in place of the column name when it retrieves values from a column. An edit string specifies a string that controls how interactive SQL or DATATRIEVE formats the display of values in a column. DEFAULT VALUE and QUERY NAME are active only from DATATRIEVE.
COLLATING_SEQUENCE_IS
The COLLATING SEQUENCE IS clause specifies a collating sequence. A collating sequence is the sequence in which characters are ordered for sorting, merging, and comparing. The VMS National Character Set (NCS) provides a set of predefined collating sequences and lets you define collating sequences of your own.
ADD_CONSTRAINT
The ADD CONSTRAINT clause adds a table constraint definition that
applies to the whole table. The four types of table constraints are
PRIMARY KEY, UNIQUE, CHECK, and FOREIGN KEY constraints. You can
also optionally specify a constraint name.
The PRIMARY KEY constraint is used to declare a column or columns as
a primary key for the table being defined. Any foreign key that
refers to this column must refer to this primary key.
The UNIQUE table constraint specifies that the combination of values
for the columns named must be unique in a row. You can use either
the UNIQUE or PRIMARY KEY keywords to define one or more columns as a
unique key for a table.
The CHECK table constraint specifies a predicate that column values
inserted into the table must satisfy. Predicates in CHECK table
constraints can refer to any column in the table. Column select
expressions within the predicate can refer to other tables in the
schema.
The FOREIGN KEY table constraint specifies the column or columns that
you want to declare as a foreign key in the table you are defining.
The optional CONSTRAINT constraint-name clause specifies a name for a
column or table constraint. The name specified is used in several
ways:
o The INTEG_FAIL error message specifies the name when an INSERT,
UDPATE, or DELETE statement violates the constraint
o ALTER TABLE DROP CONSTRAINT statements specify the name to drop a
table constraint
o SHOW TABLE statements display the names of column and table
constraints
ALTER_COLUMN
The ALTER COLUMN clause modifies the column specified by the column
name:
alter-col-definition =
─> column-name ─┬────────>───────┬─┬─────────>────────┬──┐
├─> data-type ───┤ └─> default-value ─┘ │
└─> domain-name ─┘ │
┌──────────────────────────────────────────────────────┘
└──┬┬────────────>────────────┬─┬─┐
│└─> add-col-constraint ───┘ │ │
└─────────────<──────────────┘ │
┌─────────────────────────────────┘
└──┬────────────>────────────────────┬───>
└─┬─> sql-and-dtr-clause ──────┬──┘
└──────────────<─────────────┘
Additional information available:
More Informationdata typedefault valueadd col constraintsql and dtr clause
More Information
You can modify some elements of a column definition but not others:
o You cannot change the column name.
o You can change an explicitly specified data type to another, but
use care (see notes in this argument description).
o You can add or modify the default value.
o You can change the domain referred to by a column, provided the
domain exists in the schema
o You can substitute an explicit data type for a column that
previously referred to a domain name
o If you do not want to change the data type or domain of an
existing column, you do not need to specify a data type or domain
name.
o You cannot change an existing column constraint. However, you
can drop the existing constraint and add a new column constraint
using the ALTER COLUMN statement to achieve the same result.
o You can specify any column to be NOT NULL. The only way you can
alter an existing constraint to be not null is by using the ALTER
TABLE statement.
o You can change a formatting clause by redefining clauses or
overriding existing clauses with NO options. If you add a new
clause, existing clauses are unaffected.
data type
data-type = ──┬─>
C
H
A
R ─┬────────┬───────────────────────────┬──> │ └─> (n) ─┘ │ ├─>
V
A
R
C
H
A
R (n) ───────────────────────────────┤ ├─>
L
O
N
G
V
A
R
C
H
A
R ──────────────────────────────┤ ├─>
T
I
N
Y
I
N
T ──────────────┬─────┬────────┬─────┤ ├─>
S
M
A
L
L
I
N
T ─────────────┤ └─> (n) ─┘ │ ├─>
I
N
T
E
G
E
R ──────────────┤ │ ├─>
Q
U
A
D
W
O
R
D ─────────────┤ │ ├─>
L
I
S
T
O
F
B
Y
T
E
V
A
R
Y
I
N
G ─┘ │ ├─>
D
E
C
I
M
A
L ─┬─┬─────────────────────────────┬─┤ ├─>
N
U
M
E
R
I
C ─┘ └─> ( ──> n ─┬────────┬─> ) ──┘ │ │ └─> , n ─┘ │ ├─>
F
L
O
A
T ─┬────────┬──────────────────────────┤ │ └─> (n) ─┘ │ ├─>
R
E
A
L ──────────────────────────────────────┤ ├─>
D
O
U
B
L
E
P
R
E
C
I
S
I
O
N ──────────────────────────┤ └─>
D
A
T
E ──────────────────────────────────────┘
default value
default-value = DEFAULT ──┬──>literal ─┬───> ├──>
U
S
E
R ───┤ └──>
N
U
L
L ───┘
Additional information available:
More informationliteralMore Information
More information
The default value of a column is the value stored in the database if an insert operation on a row specifies no value for that column. You can use literals, the NULL keyword, the current timestamp, or the user name as default values. If you do not specify a default value, SQL assigns NULL as the default value. If you specify a default value for a column in a table, it overrides any default value specified for the domain on which the column is based. You might have any of several possible reasons for specifying a default value for a column; for instance, you may want to store the most commonly used value, or you may want to store a value that highlights (is visual displays) the fact that no value was stored.
literal
A value expression that is either numeric, character string, or date.
USER
The user name of the process that invokes interactive SQL or runs a program.
NULL
A null value.
CURRENT_TIMESTAMP
The date and time currently defined in Rdb/VMS.
More Information
A value to be stored in a column if the row that is inserted does not include a value for that column. You can use literals, the NULL keyword, the current timestamp, or the user name as default values. If you do not specify a default value, a column inherits any default value from the domain. If you do not specify a default value for either the column or domain, SQL assigns NULL as the default value.
add col constraint
col-constraint = ─┬─>
P
R
I
M
A
R
Y
K
E
Y ──────────────────────┬──┐ ├─>
N
O
T
N
U
L
L ─────────────────────────┤ │ ├─>
U
N
I
Q
U
E ───────────────────────────┤ │ ├─>
C
H
E
C
K (predicate) ────────────────┤ │ └─> references-clause ────────────────┘ │ ┌───────────────────────<────────────────┘ └─┬─────────────────>─────────────┬─> └─>
C
O
N
S
T
R
A
I
N
T constraint-name ─┘
Additional information available:
More Informationreferences clause
More Information
The add-col-constraint clause specifies a constraint definition that
applies to an existing column. The syntax and explanation for the
add-col-constraint clause are the same as for the col-constraint
clause.
The five types of column constraints are PRIMARY KEY, NOT NULL,
UNIQUE, CHECK, and foreign key constraints. Foreign key constraints
are created with the REFERENCES clause. You can also optionally
specify a name for a constraint definition.
The PRIMARY KEY column constraint declares a column to be a primary
key. SQL requires that values in this column be unique and not null.
Therefore, you need not specify the UNIQUE and NOT NULL column
constraints for a primary key column.
The NOT NULL column constraint restricts values in the column to
non-null values.
The UNIQUE column constraint specifies that values in the column
named must be unique.
The CHECK column constraint specifies a predicate that column values
inserted into the table must satisfy. Predicates in CHECK table
constraints can refer directly only to the column with which they are
associated.
The optional CONSTRAINT constraint-name specifies a name for a column
constraint that is used in several ways:
o The INTEG_FAIL error message specifies the name when an INSERT,
UDPATE, or DELETE statement violates the constraint
o ALTER TABLE DROP CONSTRAINT statements specify the name to drop a
table constraint
o SHOW TABLE statements display the names of column and table
constraints
The name of the constraint is used in error messages and ALTER TABLE
DROP CONSTRAINT, SHOW TABLE, DECLARE TRANSACTION and SET TRANSACTION
statements. The CONSTRAINT clause is optional. If you omit the
constraint name, SQL creates a name. However, DIGITAL recommends
that you always name column and table constraints. The constraint
names generated by SQL may be obscure and, in programs, may change
between compilation and running.
references clause
references-clause =
REFERENCES referenced-table-name ───┐
┌─────────────────<────────────────┘
└─┬─────────────────────>───────────────────┬─>
└─> ( ─┬─> referenced-column-name ─┬─> ) ─┘
└─────────── , <────────────┘
Specifies the name of a column or columns that are a primary key or
unique key in the referenced table. When the REFERENCES clause is
selected as a column-constraint, the column specified in the
col-definition clause becomes a foreign key for the referencing table
(the table being defined). When the REFERENCES clause is selected as
a table constraint, the column name or column names specified in the
FOREIGN KEY clause become a foreign key for the referencing table.
The referenced_table_name is the name of the table that contains the
unique key or primary key referenced by the referencing table. You
must have the SQL access right REFERENCES or CREATETAB to the
referenced table.
For a column constraint, the referenced_column_name is the name of
the column that is a unique key or primary key in the referenced
table. For a table constraint, the referenced_column_name is the
name of the column or columns that are a unique key or primary key in
the referenced table. The unique key can be defined with either the
UNIQUE or PRIMARY KEY keywords. If you omit the
referenced_column_name, the primary key in the referenced table is
used.
sql and dtr clause
sql-and-dtr-clause = ─┬─>
Q
U
E
R
Y
H
E
A
D
E
R typebox (I)typebox (S) ─┬> quoted-string ──┬─────────────────┬─> │ └────── typebox (/) <────────┘ │ ├─>
E
D
I
T
S
T
R
I
N
G typebox (I)typebox (S) quoted-string ─────────────────────────┤ │ │ ├─>
Q
U
E
R
Y
N
A
M
E Ftypebox (O)typebox (R) ─┬─> typebox (D)typebox (T)typebox (R) ────────┬─> typebox (I)typebox (S) quoted-string ─┤ │ └─> typebox (D)typebox (A)typebox (T)typebox (A)typebox (T)typebox (R)typebox (I)typebox (E)typebox (V)typebox (E) ─┘ │ ├─>
D
E
F
A
U
L
T
V
A
L
U
E Ftypebox (O)typebox (R) ─┬─> typebox (D)typebox (T)typebox (R) ────────┬─> typebox (I)typebox (S) literal ────┤ │ └─> typebox (D)typebox (A)typebox (T)typebox (A)typebox (T)typebox (R)typebox (I)typebox (E)typebox (V)typebox (E) ─┘ │ ├─>
N
O
Q
U
E
R
Y
H
E
A
D
E
R ──────────────────────────────────────┤ ├─>
N
O
E
D
I
T
S
T
R
I
N
G ───────────────────────────────────────┤ ├─>
N
O
Q
U
E
R
Y
N
A
M
E ────┬──> Ftypebox (O)typebox (R) ─┬─> typebox (D)typebox (T)typebox (R) ────────┬─────────┘ └─>
N
O
D
E
F
A
U
L
T
V
A
L
U
E ─┘ └─> typebox (D)typebox (A)typebox (T)typebox (A)typebox (T)typebox (R)typebox (I)typebox (E)typebox (V)typebox (E) ─┘ Optional formatting clauses allow you to modify data displays or query characteristics for interactive SQL users and DATATRIEVE users. A query header specifies a string that interactive SQL or DATATRIEVE displays in place of the column name when it retrieves values from a column. An edit string specifies a string that controls how interactive SQL or DATATRIEVE formats the display of values in a column. DEFAULT VALUE and QUERY NAME are active only from DATATRIEVE.
COLLATING_SEQUENCE_IS
Specifies a new collating sequence for the named domain.
DROP_COLUMN
The DROP COLUMN statement deletes the specified column.
DROP_CONSTRAINT
The DROP CONSTRAINT statement deletes the specified column constraint or table constraint from the table definition.