RDB/VMS SQL ALTER — VMS RDB_4.2
Changes definitions for VAX SQL.
Additional information available:
DATABASESTORAGE_MAPDOMAININDEXSCHEMATABLE
DATABASE
ALTER DATABASE -+-> PATHNAME path-name -+--+
+-> FILENAME file-spec -+ |
+---------------<--------------------------+
++------------->--------------+------------+
+-> alter-root-file-params1 -+ |
+------------------------------------------+
++-------------->-------------+------------+
+-> alter-root-file-params2 -+ |
+------------------------------------------+
++-------------->----------------+---------+
+-> alter-storage-area-params --+ |
+---------------<--------------------------+
+++--------------------------->------------------++>;
|+-> ADD STORAGE AREA area-name ----------+ ||
||+---------------------------------------+ ||
||++----------->---------+> storage-area-params-+|
|| +> FILENAME file-spec + ||
|+> ALTER STORAGE AREA area-name --------+ ||
||+--------------------------------------+ ||
||+> alter-storage-area-params -----------------+|
|+> DROP STORAGE AREA area-name ----------------+|
+-----------------------------<------------------+
Additional information available:
ADD_STORAGE_AREAALTER_STORAGE_AREADROP_STORAGE_AREA
More Informationalter root file params1alter root file params2alter storage area params
storage area params
More Information
Alters a database in any of the following ways:
o For both single-file and multifile databases, changes
characteristics of the database root file associated with a
database. ALTER DATABASE allows you to override certain
characteristics specified in the root file parameters of a CREATE
DATABASE statement, such as whether the snapshot file is
disabled. In addition, ALTER DATABASE lets you control other
characteristics that you cannot specify in CREATE DATABASE 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.
ADD_STORAGE_AREA
Specifies the name and file specification for a storage area you want to add to the database. You can use the ADD STORAGE AREA clause only on multifile databases. The storage area name cannot be the same as any other storage area name in the database. The ADD STORAGE AREA clause creates two files, a storage area file with a file type of .RDA 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 directory 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 types, do not specify a file type with the file specification. If you use the ALTER DATABASE statement to add a storage area, the change will not be journaled. You should, therefore, back up your database before making such a change. See the Usage Notes for important information about changes that are not journaled.
ALTER_STORAGE_AREA
Specifies the name of an existing storage area in the database that you want to alter. You can use the ALTER STORAGE AREA clause only on multifile databases. SQL generates an error if you specify RDB$SYSTEM as the storage area name in the ALTER STORAGE AREA clause. If you want to change the parameters of the RDB$SYSTEM storage area using the ALTER DATABASE statement, you must specify the storage area parameters outside of the ALTER STORAGE AREA clause.
alter root file params1
alter-root-file-params1 = +-+-+-> MULTISCHEMA IS -----+--> ON ---+----------+-+-+> | | | +--> OFF --+ | | | | | +-> OPEN IS ------------+--> AUTOMATIC -+----+ | | | | | +--> MANUAL -----+ | | | | | +-> READ WRITE -------------------------------+ | | | | +-> NUMBER OF USERS IS --> number-users ------+ | | | | +-> NUMBER OF BUFFERS IS --> number-buffers --+ | | | | +-> NUMBER OF VAXCLUSTER NODES IS ----------+ | | | | | | +--------------------------------------+ | | | | | | +-> number-nodes ------------------------+ | | | | +-> NUMBER OF RECOVERY BUFFERS IS ----------+ | | | | | | +--------------------------------------+ | | | | | | +-> number-buffers ----------------------+ | | | | +-> SNAPSHOT IS -+> ENABLED -+------->-----+-++ | | | | | | +> IMMEDIATE -+ | | | | | | | +> DEFERRED --+ | | | | | | +> DISABLED ----------------+ | | | | +-> global-buffers-params ----------------------+ | | +----------------------------<--------------------+ | +-----> READ ONLY ------------->----------------------+
Additional information available:
More Informationglobal buffer params
More Information
Parameters that control the characteristics of the database root file associated with the database, 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 DATABASE does not allow you to change all root file parameters you can specify in CREATE DATABASE. 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 o PROTECTION IS ACL
global buffer params
global-buffer-params=
-> GLOBAL BUFFERS ARE -+-> ENABLED --+---+
+-> DISABLED -+ |
+----------------------------------------+
+-+-----------------------------------------------+->
+-> ( -> NUMBER IS number-glo-buffers -> , --+ |
+---------------------------------------+ |
+-> USER LIMIT IS max-glo-buffers ----> ) -+
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 = -+-+-> DICTIONARY IS ------+-> REQUIRED -------+---------+-+> | | +-> NOT REQUIRED ---+ | | | +-> ADJUSTABLE LOCK GRANULARITY IS -+-+-> ENABLED ----+ | | +-> CARRY OVER LOCKS ARE -----------+ +-> DISABLED ---+ | | +-> LOCK TIMEOUT INTERVAL IS number-seconds SECONDS --+ | | +-> JOURNAL FILENAME file-spec -----------------------+ | | +-> JOURNAL ALLOCATION IS -> journal-blocks -> BLOCKS + | | +-> JOURNAL EXTENT IS ---> extent-blocks --> BLOCKS --+ | | +-> NO JOURNAL ---------------------------------------+ | | +-> journal-fast-commit-clause -----------------------+ | +---------------------------------------------------------+
Additional information available:
More Informationjournal fast commit clause
More Information
Parameters that control the characteristics of the database root file associated with the database, 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. DICTIONARY IS REQUIRED specifies that definition statements issued for the database must also stored in the data dictionary. ADJUSTABLE LOCK GRANULARITY Enables or disables whether or not the database system will automatically maintain as few locks as possible on database resources. The default is ENABLED, and results in fewer locks against the database. JOURNAL FILENAME specifies the file for the database system to use as the after-image journal (.AIJ) file. By default, when you create a database, after-image journaling is disabled. Specifying an .AIJ file in the ALTER DATABASE statement enables after-image journaling. JOURNAL ALLOCATION IS specifies the number of blocks allocated for the .AIJ file. The default is 0 blocks. JOURNAL EXTENT IS specifies the number of blocks of each .AIJ file extent. The default extent for .AIJ files is 512 blocks. NOJOURNAL discontinues after-image journaling for databases that previously had it enabled.
journal fast commit clause
journal-fast-commit-clause =
-> JOURNAL FAST COMMIT --+-> ENABLED --+-----+
+-> DISABLED -+ |
+-------------------------------------------+
++-----------------------------------------------+>
+>(++-> CHECKPOINT INTERVAL IS n BLOCKS ----++>)+
|+-> CHECKPOINT TIMED EVERY n SECONDS ---+|
|+-> COMMIT TO JOURNAL OPTIMIZATION -----+|
|+-> NO COMMIT TO JOURNAL OPTIMIZATION --+|
|+-> TRANSACTION INTERVAL IS number-txns +|
+-------------------- , <-----------------+
Additional information available:
More Information
JOURNAL FAST COMMIT ENABLED specifies that Rdb/VMS keeps updated pages in the buffer pool and does not write the pages to disk each time a transaction commits. The updated pages can remain in the buffer pool until a user-specified threshold (called a checkpoint) is reached. At checkpoint, Rdb/VMS writes all the updated pages for multiple transactions to disk. If a transaction fails, Rdb/VMS rolls back the current, failed transaction and reprocesses all the committed transactions since the last checkpoint. Fast commit processing applies only to erase, modify, and store operations. Transactions that include data definition statements, such as create logical area or create index operations, force a checkpoint at the end of the transaction. You can specify a checkpoint after a certain number of blocks using the CHECKPOINT INTERVAL IS clause or after a time period using the CHECKPOINT TIMED EVERY clause. If you specify both types of checkpoints, Rdb/VMS checkpoints at whichever one it reaches first. If you enable COMMIT TO JOURNAL OPTIMIZATION when you enable fast commit, Rdb/VMS does not write commit information to the database root file. This option enhances performance in database environments that are update intensive. Because of the prerequisites for enabling the journal optimization option, general use databases or databases that have many read-only transactions may not benefit from this feature. For more information see the VAX Rdb/VMS Guide to Database Maintenance and Performance. The TRANSACTION INTERVAL IS n clause specifies the size of the TSN range where n equals the number of TSNs (transaction sequence numbers). Rdb/VMS uses transaction sequence numbers to ensure database integrity. When you specify NO COMMIT TO JOURNAL OPTIMIZATION, TSNs are assigned to users one at a time. When the journal optimization option is enabled, each user is pre-assigned a range of TSNs. Assigning a range of TSNs avoids the single-threading problem because commit information need not be written to the database root for each transaction. Rdb/VMS writes all transaction information to the .AIJ file except for each user's allocated TSN range, which it writes to the root. The transaction interval value (the TSN range) must be a number between 8 and 1024. The default value is 256. You need to decide which constraint has precedence on your database: performance or running out of TSNs. As a general guideline, if your database has few users or if all user sessions are long, select a high transaction interval. If your database has many users or if user sessions are short, select a smaller transaction interval.
Example
The following example changes the CORPORATE_DATA database so that after-image journaling and fast commit processing are enabled. SQL> ALTER DATABASE FILENAME CORPORATE_DATA cont> JOURNAL FILENAME DISK01:[DEPT3.SQL]CORP_DATA.AIJ cont> JOURNAL FAST COMMIT ENABLED cont> (CHECKPOINT INTERVAL IS 100 BLOCKS, cont> CHECKPOINT TIMED EVERY 10 SECONDS); %RDMS-I-AIJMODSEQ, next AIJ file sequence number will be 2 SQL>
alter storage area params
alter-storage-area-params = -+-+-+---> READ WRITE --------------------------------------++-> | | +-+-> EXTENT IS +-> ENABLED ----+---------------------++| | | | | +-> DISABLED ---+ ||| | | | | +-> extent-pages ---------> PAGES --+-+|| | | | | +-> (extension-options) ------------+ ||| | | | +-------------------------<-------------------------+|| | | +---> SNAPSHOT ALLOCATION IS -> snp-pages --> PAGES ---+| | | +---> SNAPSHOT EXTENT IS -+> extent-pages -> PAGES -+--+| | | +> (extension-options) ---+ || | +-------------------------------<------------------------+| +-------> READ ONLY ----------------------------------------+ +-------> WRITE ONCE ---------------------------------------+
Additional information available:
EXTENTEXTENT_ISREAD_ONLYREAD_WRITE
SNAPSHOT_ALLOCATION_ISSNAPSHOT_EXTENT_ISWRITE_ONCE
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 DATABASE statement differs:
o For single-file databases, the storage area parameters change the
characteristics for the single storage area in the database.
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 storage area in the ALTER
STORAGE AREA clause, so specifying the parameters in this part of
the ALTER DATABASE statement is the only way to change the
parameters of the RDB$SYSTEM storage area using the ALTER
DATABASE statement.
Note that the ALTER DATABASE statement does not allow you to change
all storage area parameters you can specify in the CREATE DATABASE
statement. You must use the EXPORT and IMPORT statements to change
the following database root file parameters:
o ALLOCATION
o PAGE SIZE
o PAGE FORMAT
o THRESHOLDS
o INTERVAL
o SNAPSHOT FILENAME
EXTENT
Enables or disables extents. Extents are ENABLED by default, and can be changed online, but the new extents are not immediately effective on all nodes of a cluster. On the node on which you have changed extents, the new storage area extents are immediately effective for all users. The new storage area extents become effective as the database is attached on each node of the cluster. Disabling extents helps diagnose performance problems caused by faulty area sizing when creating hashed with mixed page format.
EXTENT_IS
Changes the number of pages of each storage area file extent. See the description under the "SNAPSHOT EXTENT" argument.
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 Have snapshot files, but do not use them. (Data in a read-only
storage area is not updated; specify a small number for the
initial snapshot file size for a read-only storage area.)
o Eliminate page and record locking in the read-only storage areas.
o Are backed up by the RMU/BACKUP command by default unless you
explicitly state /NOREAD_ONLY which excludes read-only areas
without naming them.
o Are restored by the RMU/RESTORE command if they were previously
backed up.
o Are recovered by the RMU/RECOVER command. However, unless the
read-only attribute was modified, the read- only area does not
change.
o Are not recovered by the RMU/RECOVER/AREA=* command, where you
are not explicitly naming the areas needing recovery, unless they
are inconsistent.
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.
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".
SNAPSHOT_ALLOCATION_IS
Changes the number of pages allocated for the snapshot file. The default is 100 pages. If you have disabled the snapshot file, you can set the snapshot allocation to 0 pages.
SNAPSHOT_EXTENT_IS
Changes the number of pages of each snapshot or storage area file extent. The default extent for storage area files is 100 pages. Specify a number of pages for simple control over the file extent. For greater control, and particularly for multivolume databases, use the MINIMUM, MAXIMUM, and PERCENT GROWTH extension options instead. If you use the MINIMUM, MAXIMUM, and PERCENT GROWTH parameters, you must enclose them in parentheses.
WRITE_ONCE
Permits you to change any storage area that contains only a segmented
string to a format that can be stored on a write-once, read-many
(WORM) device.
You can use the WRITE ONCE option to change a storage area containing
stable database list (segmented string) data to a format that can be
stored on a write-once, read-many (WORM) optical disk. A WORM
optical disk offers a relatively inexpensive way of storing large
amounts of data for read-only access compared to other storage media.
Rdb/VMS supports the Perceptics WORM optical disk drive and juke box
as a storage media for storing lists or segmented string data.
Example 2 at the end of this section shows how to change a read/write
storage area to a write-once storage area.
5More_Information
The following restrictions apply to the WRITE ONCE option:
o You cannot write data other than segmented strings to a
write-once storage area. Rdb/VMS issues an error message if you
try to create a storage map that stores data other than segmented
strings in a write-once storage area. Storage maps for
non-segmented-string data must be removed before you can alter a
storage area to WRITE ONCE.
o When you create a storage area on WORM media, you must specify
that the snapshot area remains on read/write media; do not give a
snapshot file the WRITE ONCE attribute.
o If you specify the WRITE ONCE option when storing a segmented
string, database keys are not compressed.
o Although write-once storage areas do not use SPAM pages to look
for storage space, but to assist moving data back to non-WORM
media in which SPAM pages must be built again, space is still
allocated for them. Because SPAM pages are essential in uniform
areas, write-once storage areas can of uniform format and
therefore are required to be of mixed format.
o You can use the PAGE SIZE IS clause of CREATE STORAGE AREA to
change the default page size for a storage area. To optimize
storage, always specify an even number of blocks per page.
o Digital does not support magnetic media for storing write-once
storage areas.
o After you move a storage area to or from a WORM device, Digital
recommends that you back up your database completely and start a
new after-image journaling file.
extension options
extention-options = ---> MINIMUM OF min-pages PAGES, ---+ +-----------------------------------+ +--> MAXIMUM OF max-pages PAGES, ---+ +-----------------------------------+ +--> PERCENT GROWTH IS growth ---------> Changes the number of pages of each snapshot or storage area file extent.
Additional information available:
MINIMUM_OFMAXIMUM_OFPERCENT_GROWTH_IS
MINIMUM_OF
Specifies the minimum number of pages of each extent. The default is 100 pages.
MAXIMUM_OF
Specifies the maximum number of pages of each extent. The default is 10,000 pages.
PERCENT_GROWTH_IS
Specifies the percent growth of each extent. The default is 20 percent growth.
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 DATABASE 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.
storage area params
storage-area-params = -++-------------------------->-----------------------------++-> |+-> ALLOCATION IS ---> number-pages ----> PAGES ---------+| |+-> PAGE SIZE IS ----> page-blocks -----> BLOCKS --------+| |+-> PAGE FORMAT IS --+----> UNIFORM ----+----------------+| || +----> MIXED ------+ || |+-> THRESHOLDS ARE ( val1 -+----------------------+-> ) -+| || +-> ,val2 -+----------++ || || +-> ,val3 -+ || |+-> INTERVAL IS -------> number-data-pages --------------+| |++> EXTENT IS ----+--> ENABLED ---------------------+-+--+| ||| +--> DISABLED --------------------+ | || ||| +--> extent-pages ----> PAGES ----+ | || ||| +--> (extension-options) ---------+ | || ||+----------------------------<-----------------------+ || |+-> SNAPSHOT FILENAME ---> file-spec --------------------+| |+-> SNAPSHOT ALLOCATION IS --> snp-pages --> PAGES ------+| |+-> SNAPSHOT EXTENT IS -+-> extent-pages --> PAGES -+----+| || +-> (extension-options) ----+ || |+-> WRITE ONCE ------------------------------------------+| +-----------------------------<----------------------------+ Parameters that control the characteristics of the storage area.
STORAGE_MAP
ALTER STORAGE MAP map-name -+
+---------------------------+
+--+-+-> store-clause ---------------------+-+--+-->;
| +-> threshold-clause -----------------+ | |
| ++-> ENABLE --+-> COMPRESSION --------+ | |
| |+-> DISABLE -+ | | |
| +-> NO PLACEMENT VIA INDEX -----------+ | |
| +-> PLACEMENT VIA INDEX index-name ---+ | |
| +-> REORGANIZE --> --+---->------+------+ |
| +-> AREAS --+ |
| +-> PAGES --+ |
+--------------------<-----------------------+
Additional information available:
More Informationstore clausethreshold clausestore lists clause
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
o Which columns of the table will be stored in an area
store clause
store clause =
-> STORE ---+----------------------------------------+-->
+-> IN area-name ---------------------+ |
| +----------------------------------+ |
| ++----------------------------------+-+
| +-> ( --> threshold-clause --> )---+ |
+-> across-clause -----------------------+
+-> using-clause ------------------------+
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.
This is called horizontal partitioning.
threshold clause
threshold-clause =
-+-> THRESHOLD -+-> IS -+-> ( --> val1 --> ) -----+->
| +-> OF -+ |
| |
+-> THRESHOLDS -+-> ARE -+-----------+ |
+-> OF -+ | |
+----------------------------------+ |
+-> ( --> val1 -+-----------------------+-> ) -+
+-> , val2 -+-----------+
+-> , val3 -+
Additional information available:
More Information
You can specify up to three SPAM thresholds for storage areas with mixed format pages and logical areas in storage areas with uniform format pages. The value val represents the percentage of the partition. You can specify a default threshold for a new logical area using the THRESHOLDS ARE clause in the ALTER STORAGE MAP statement. To specify thresholds for a particular storage area, each storage area mentioned in the STORE clause can be followed by a THRESHOLDS ARE clause. Thresholds are not allowed for segmented string storage areas. The THRESHOLD clause only applies to new areas: you cannot change a threshold for a logical area. Although a threshold clause associated with a particular area is enclosed in parentheses, the default threshold clause for a storage map is not. (The threshold clause associated with a particular area appears within the store clause.)
store lists clause
store-lists-clause =
---> STORE LISTS ---+
+------------------+
+-+-> IN -+-> area-name ----------+--------+---------->
| +-> (-+> area-name + ) -+ |
| +---- , <----+ |
| +---------------------------------------+
| +-+------------------------------------------------->-+
| +-> FOR -> ( -+-> table-name -----------+-> ) -+ |
| +-> table-name. col-name -+ | |
| +-------- , <-------------+ | |
| +--------------------------------------+ |
| +---+-----------------------+------------->-+
| +-> FILL RANDOMLY -----+ |
| +-> FILL SEQUENTIALLY --+ |
+----<--------------------------------------<-----------+
Additional information available:
More Information
Directs the database system to store the lists from tables in a specified storage area or in a set of areas. You can create only one storage map for lists within each database. You must specify a default storage area for lists in the STORE LISTS clause. The default list storage area contains lists from system tables as well as lists not directed elsewhere by the STORE LISTS clause. You can also use the LIST STORAGE AREA clause of the CREATE DATABASE statement to specify a default storage area for lists. If you do not use the STORE LISTS clause and do not specify a list storage area in the CREATE DATABASE statement, Rdb/VMS uses RDB$SYSTEM as the default list storage area.
FOR
o (table-name)
Specifies the table or tables to which this storage map will
apply. If you want to store lists of more than one table in the
storage area, separate the names of the tables with commas. For
each area, you can specify one FOR clause and list of
table-names.
o (table-name.col-name)
Specifies the name of the table and column containing the list to
which this storage map will apply. Separate the table name and
the column name with a period (.). If you want to store multiple
lists in the storage area, separate the table name-column name
combinations with commas. For each area, you can specify one FOR
clause and list of column names. You cannot specify the same
table and column name more than once in the same storage map.
Additional information available:
FILL RANDOMLY and FILL SEQUENTIALLY
FILL RANDOMLY and FILL SEQUENTIALLY
Specifies whether to fill the area set randomly or sequentially. Specifying FILL RANDOMLY or FILL SEQUENTIALLY requires a FOR clause. When a storage area is filled, it is removed from the list of available areas. Rdb/VMS does not attempt to store any more lists in that area during the current database attach. Instead, Rdb/VMS starts filling the next specified area. When a set of areas is filled sequentially, Rdb/VMS stores lists in the first specified area until that area is filled. Use sequential filling when storing lists in write- once storage areas in a jukebox environment to avoid excess swapping of platters. In a jukebox environment, the filled storage area is marked with a FULL flag and the platter on which the area resides is no longer swapped in. If the set of areas is filled randomly, lists are stored across multiple areas. This is the default. Random filling is intended for read/write media which will benefit from the I/O distribution across the storage areas. The keywords FILL RANDOMLY and FILL SEQUENTIALLY can only be applied to areas contained within an area list.
Example
The following example causes list data to be stored in several
storage areas. You cannot control which records are stored in which
storage areas, nor can you use ALTER STORAGE MAP to move list data to
another storage area.
SQL> ALTER STORAGE MAP LISTS_MAP
cont> STORE LISTS IN RDB$SYSTEM
cont> FOR (RESUMES.RESUME)
cont> IN RESUME_LISTS
cont> FOR (RESUMES.RESUME)
cont> IN RESUME_LISTS2
cont> FOR (RESUMES.RESUME);
SQL> SHOW STORAGE MAP LISTS_MAP
LISTS_MAP
For Lists
Store clause: STORE LISTS IN RDB$SYSTEM
FOR (RESUMES.RESUME)
IN RESUME_LISTS
FOR (RESUMES.RESUME)
IN RESUME_LISTS2
FOR (RESUMES.RESUME)
The following example creates a new column for an existing table, and
alters the storage map to specify a storage area for that column.
SQL> ALTER TABLE RESUMES ADD PICTURE LIST OF VARBYTE.
SQL> ALTER STORAGE MAP LISTS_MAP
cont> STORE LISTS IN RESUME_LISTS FOR (RESUMES.RESUME)
cont> IN RESUME_LISTS2
cont> FOR (RESUMES.PICTURE);
DOMAIN
ALTER DOMAIN ----+
+---------------+
+->domain-name +-----------------+-+-----------------++
+-> IS data-type -+ +->default-value -+|
+-----------------------------------------------------+
+-+--------------------------------------------+--+
+---> COLLATING SEQUENCE IS sequence-name ---+ |
+---> NO COLLATING SEQUENCE -----------------+ |
+-----------------------------------------+
+--+--------------------------+--> ;
++-> sql-and-dtr-clause --++
+-------<----------------+
Additional information available:
COLLATING_SEQUENCE_ISNO_COLLATING_SEQUENCE
More Informationdomain namedata typedefault valuesql and dtr clause
More Information
Alters a domain definition. This allows you to change the character set, data type, optional default value, optional collating sequence, or optional formatting and DATATRIEVE clauses associated with a domain name. Any table definitions that refer to that domain reflect the changes. 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 attached to the database 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. You can change the character set associated with a domain name. However, if this is done after data is entered into a table using the domain name, SQL returns a data conversion error when you try to select rows from that table. If a domain definition is stored in the data dictionary, the ALTER DOMAIN statement alters the domain definition in the data dictionary.
domain name
The name of a domain you want to alter. The domain name must be unique among domain names in the schema.
data type
data-type = -+-> char-data-types ---------------------------+--> +-> TINYINT --------------+-----+--------+-----+ +-> SMALLINT -------------+ +-> (n) -+ | +-> INTEGER --------------+ | +-> BIGINT ---------------+ | +-> LIST OF BYTE VARYING -+ | +-> DECIMAL -+-+-----------------------------+-+ +-> NUMERIC -+ +-> ( --> n -+--------+-> ) --+ | | +-> , n -+ | +-> FLOAT -+--------+--------------------------+ | +-> (n) -+ | +-> REAL --------------------------------------+ +-> DOUBLE PRECISION --------------------------+ +-> date-time-data-types ----------------------+
Additional information available:
char data types
char-data-types = -+-> CHAR +--------+-+-------------------------------------+-+-> | +-> (n) -+ +-> CHARACTER SET character-set-name -+ | +-> NCHAR ---------+-+--------+------------------------------+ +-> NATIONAL CHAR -+ +-> (n) -+ | +-> VARCHAR (n) -----+-------------------------------------+-+ | +-> CHARACTER SET character-set-name -+ | +-> NCHAR VARYING ----------+------+---------+---------------+ +-> NATIONAL CHAR VARYING --+ +-> (n) --+ | +-> LONG VARCHAR -------------------------------------------+
Additional information available:
character set nameNCHAR or NATIONAL CHARNCHAR VARYING or NATIONAL CHAR VARYING
CHAR
The CHAR data type can be qualified by the keywords CHARACTER SET and the character set name.
character set name
A valid character set for database object names.
NCHAR or NATIONAL CHAR
The NCHAR or NATIONAL CHAR data type has the same characteristics as CHAR, except that the character set is that specified as the national character set.
NCHAR VARYING or NATIONAL CHAR VARYING
The NCHAR VARYING or NATIONAL CHAR VARYING data type has the same characteristics as VARCHAR, except that the character set is that specified as the national character set.
VARCHAR
The VARCHAR data type can be qualified by the keywords CHARACTER SET and the character set name. This data type has the same characteristics as CHAR, except that the character set is that specified in the CHARACTER SET clause.
default value
default-value =
DEFAULT --+-->literal -----------+->
+-->USER -------------+
+-->NULL -------------+
+-->CURRENT_DATE -----+
+-->CURRENT_TIME -----+
+-->CURRENT_TIMESTAMP -+
Additional information available:
USERNULLCURRENT_DATECURRENT_TIMECURRENT_TIMESTAMP
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_DATE
DATE data type value containing year, month, and day for date 'today'.
CURRENT_TIME
TIME data type value containing hour, minute, and second for time 'now'.
CURRENT_TIMESTAMP
TIMESTAMP data type value containing year, month, and day for date 'today' and hour, minute, and second for time 'now' 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 (visually 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 database in the CREATE DATABASE or ALTER DATABASE statement, or the domain in the CREATE DOMAIN statement.
sql and dtr clause
sql-and-dtr-clause =
-+-> QUERY HEADER IS -+> quoted-string --+-----------------+->
| +------ / <--------+ |
+-> EDIT STRING IS quoted-string -------------------------+
| |
+-> QUERY NAME FOR -+-> DTR --------+-> IS quoted-string -+
| +-> DATATRIEVE -+ |
+-> DEFAULT VALUE FOR -+-> DTR --------+-> IS literal ----+
+-> DATATRIEVE -+
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 -+
|
+----------------------+
++-------------------------------------+-+
+-+-+-> NODE SIZE number-bytes ---+-+-+ |
| +-> PERCENT FILL percentage --+ | |
| +-> USAGE --+-> UPDATE ---+---+ | |
| +-> QUERY ----+ | |
+---------- <---------------------+ |
|
+----------------------------------------+
++-------------------------+---------------> ;
+-> index-store-clause ---+
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
o Thresholds for the logical storage areas that will contain the
index
You cannot change:
o The columns that comprise an index
o Whether the index is UNIQUE
o A hashed index 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 -+
+---------------------------+
++-> IN area-name ---+--------------------------------+-+->
| +-> ( -> threshold-clause -> ) --+ |
| |
+-> USING -> ( -+-> column-name -+-> ) -------------+ |
+--------<-------+ | |
+---------------------------------------------------+ |
++> IN area-name -+-------------------------------+-+ |
| +-> ( -> threshold-clause -> ) -+ | |
| +------------------------------------------------+ |
| +-> WITH LIMIT OF -> ( -+-> literal -+-> ) ------+-+|
| +------<-----+ | ||
+---------------------<----------------------------+ ||
||
+------------------------------------------------------+|
+--> OTHERWISE IN area-name -----+ |
+----------------------------+ |
+-+----------------------------------+--------------+
+-> ( --> threshold-clause ---> ) -+
Additional information available:
threshold clauseMore Information
threshold clause
threshold-clause =
-+-> THRESHOLD -+-> IS -+-> ( --> val1 --> ) -----+->
| +-> OF -+ |
| |
+-> THRESHOLDS -+-> ARE -+-----------+ |
+-> OF -+ | |
+----------------------------------+ |
+-> ( --> val1 -+-----------------------+-> ) -+
+-> , val2 -+-----------+
+-> , val3 -+
More Information
A storage map definition for the index. You can specify a store
clause for indexes in a multifile database 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.
o You can specify a different SPAM threshold for each logical area
that is created by a storage map. You can specify a default
threshold for any new logical area using the THRESHOLDS ARE
clause in the ALTER INDEX statement.
To specify thresholds for a particular storage area, each storage
area mentioned in the STORE clause can be followed by a
THRESHOLDS ARE clause. The value val represents the percentage
of the partition.
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.
SCHEMA
The ALTER SCHEMA statement is supported only for upward compatibility. For information on altering databases see the Help topic on ALTER DATABASE.
TABLE
ALTER TABLE --> table-name --+ +----------------------------+ +-+-+-> ADD -+-> COLUMN col-definition ---------+--> ; | | +-> CONSTRAINT table-constraint ---+ | +-> ALTER alter-col-definition -------------+ | +-> DROP -+-> COLUMN column-name -----------+ | +-> CONSTRAINT constraint-name ---+ +---------------------<-----------------------+
Additional information available:
ADD_COLUMNADD_CONSTRAINTDROP_COLUMNDROP_CONSTRAINT
More Informationtable namealter col definition
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 Modify character sets o Modify data types o Delete columns o Delete constraints
table name
The name of the table whose definition you want to change.
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.
col-definition =
-> column-name ----+
+---------------+
+-+-> data-type ---+-+------------------+-+
| +-> domain-name -+ +-> default-value -+ |
| +---------------------------------------+
| ++-------------------+-+-----------------------+-+->
| ++> col-constraint ++ +-> sql-and-dtr-clause -+ |
| +--------<--------+ |
+--> COMPUTED BY value-expr -----------------------+
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 typedomain namedefault valuecol constraintsql and dtr clause
data type
data-type = -+-> char-data-types ---------------------------+--> +-> TINYINT --------------+-----+--------+-----+ +-> SMALLINT -------------+ +-> (n) -+ | +-> INTEGER --------------+ | +-> BIGINT ---------------+ | +-> LIST OF BYTE VARYING -+ | +-> DECIMAL -+-+-----------------------------+-+ +-> NUMERIC -+ +-> ( --> n -+--------+-> ) --+ | | +-> , n -+ | +-> FLOAT -+--------+--------------------------+ | +-> (n) -+ | +-> REAL --------------------------------------+ +-> DOUBLE PRECISION --------------------------+ +-> date-time-data-types ----------------------+
Additional information available:
More-Informationchar data types
More-Information
A valid SQL data type. Specifying an explicit data type to associate
with a column is an alternative to specifying a domain name.
Using the ALTER clause to change the data type of a column (directly
or indirectly by specifying a domain) requires caution:
o If you change a column to a data type with a larger capacity, or
increase the scale factor for a column, you may have to modify
source programs that refer to the column and precompile them
again.
o If you change a column to a data type with a smaller capacity,
SQL truncates values already stored in the database that exceed
the capacity of the new data type, but only when it retrieves
those values. (The values are not truncated in the database,
however, until they are updated. If you only retrieve data,
therefore, you can change the data type back to the original, and
SQL again retrieves the entire original value.)
o You can change a DATE column only to a character data type (CHAR,
VARCHAR, LONG VARCHAR, NCHAR, NATIONAL CHAR, NCHAR VARYING, or
NATIONAL CHAR VARYING). If you attempt to change a DATE column
to anything but a character data type, you could get unexpected
results.
char data types
char-data-types = -+-> CHAR +--------+-+-------------------------------------+-+-> | +-> (n) -+ +-> CHARACTER SET character-set-name -+ | +-> NCHAR ---------+-+--------+------------------------------+ +-> NATIONAL CHAR -+ +-> (n) -+ | +-> VARCHAR (n) -----+-------------------------------------+-+ | +-> CHARACTER SET character-set-name -+ | +-> NCHAR VARYING ----------+------+---------+---------------+ +-> NATIONAL CHAR VARYING --+ +-> (n) --+ | +-> LONG VARCHAR -------------------------------------------+ A charcter-set-name is a valid character set for database object names.
domain name
The name of a domain created in a CREATE DOMAIN statement. SQL gives the column the data type specified in the domain.
default value
default-value =
DEFAULT --+-->literal -----------+->
+-->USER -------------+
+-->NULL -------------+
+-->CURRENT_DATE -----+
+-->CURRENT_TIME -----+
+-->CURRENT_TIMESTAMP -+
Additional information available:
USERNULLCURRENT_DATECURRENT_TIMECURRENT_TIMESTAMP
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 (visually 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_DATE
DATE data type value containing year, month, and day for date 'today'.
CURRENT_TIME
TIME data type value containing hour, minute, and second for time 'now'.
CURRENT_TIMESTAMP
TIMESTAMP data type value containing year, month, and day for date 'today' and hour, minute, and second for time 'now' currently defined in Rdb/VMS.
col constraint
col-constraint=
---+----------------->------------+---+
+->CONSTRAINT constraint-name -+ |
+------------------------------------+
+-> PRIMARY KEY -----------------+
+-> UNIQUE ----------------------+
+-> NOT NULL --------------------+
+-> CHECK (predicate) -----------+
+-> references-clause -----------+
+------------>-------------------+
+-------------<------------------+
+----+----------------------------+-->
+--> constraint-attributes --+
Additional information available:
constraint nameMore Informationreferences clauseconstraint attributes
constraint name
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.
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.
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 to declare a constraint that refers to another
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.
constraint attributes
constraint-attributes =
----+----> --+- DEFERRABLE -------->
+-> NOT -+
There are two constraint-attributes:
Specifying NOT DEFERRABLE means that evaluation of the constraint
must take place when the INSERT, DELETE, or UPDATE statement
executes.
Specifying DEFERRABLE means that evaluation of the constraint can
take place at any later time. Unless otherwise specified, evaluation
of the constraint will take place as the COMMIT statement executes.
You can use the SET ALL CONSTRAINTS statement to have all constraints
evaluated earlier. See the SET ALL CONSTRAINTS statement for more
information.
If you are using the default SQLV40 dialect, the default
constraint-attribute is DEFERRABLE. When using this dialect, Rdb/VMS
displays a deprecated feature message for all constraints defined
without specification of one of the constraint attributes. The
default constraint-attribute may change in a future release. If you
are using the SQL92 dialect, the default is NOT DEFERRABLE.
sql and dtr clause
sql-and-dtr-clause =
-+-> QUERY HEADER IS -+> quoted-string --+-----------------+->
| +------ / <--------+ |
+-> EDIT STRING IS quoted-string -------------------------+
| |
+-> QUERY NAME FOR -+-> DTR --------+-> IS quoted-string -+
| +-> DATATRIEVE -+ |
+-> DEFAULT VALUE FOR -+-> DTR --------+-> IS literal ----+
+-> DATATRIEVE -+
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.
COMPUTED_BY
The COMPUTED BY clause specifies that the value of this column is calculated from values in other columns and constant expressions. You can use the ALTER TABLE COMPUTED BY clause to add a computed column to an existing table, but you cannot use it to alter an existing column into a computed column. In a COMPUTED BY clause, the column name that you supply in your column definition must be different from the name of any other existing column in the table. Any column that you refer to in the definition of a computed column cannot be deleted from that table unless you first delete the computed column. SQL does not allow UNIQUE or PRIMARY KEY constraints, REFERENCE clauses, default values, or default values for DATATRIEVE in computed columns.
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.
Additional information available:
table constraint
table-constraint =
---+---------------->------------------+----+
+-> CONSTRAINT constraint-name -----+ |
+------------------------------------------+
+-> PRIMARY KEY -> ( -+-> column-name -+-> ) ------+
| +------- , <-----+ |
+-> UNIQUE -> ( -+-> column-name -+-> ) -----------+
| +------- , <-----+ |
+-> CHECK (predicate) -----------------------------+
+-> FOREIGN KEY -> ( -+-> column-name -+-> ) --+ |
+------- , <-----+ | |
+-----------------------<--------------------+ |
+-> references-clause ------------->-------------+
+------------------------------------------------+
+-----+---------------------------+------------->
+-> constraint-attributes --+
Additional information available:
More Informationreferences clauseconstraint attributes
More Information
The CONSTRAINT clause specifies a name for the table-constraint. The
name is used for a variety of purposes:
o The INTEG_FAIL error message specifies the name when an INSERT,
UDPATE, or DELETE statement violates the constraint
o The ALTER TABLE DROP CONSTRAINT statements specify the constraint
name
o The SHOW TABLE statements display the names of constraints
o The EVALUATING clause of SET and DECLARE TRANSACTION statements
specifies constraint names
The PRIMARY KEY constraint is used to declare a column or columns as
a primary key for the table being altered. Any foreign key that
refers to this column must refer to this primary key.
The UNIQUE table constraint specifies the name of a column or columns
in the table being defined that are part of a unique key.
The CHECK table constraint specifies a predicate that column values
inserted into the table must satisfy. Predicates in CHECK column
constraints can refer directly only to the column with which they are
associated. 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 altering
(the referencing table).
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 table constraint, the column name or column names
specified in the FOREIGN KEY clause become a foreign key for the
referencing table.
constraint attributes
constraint-attributes =
----+----> --+- DEFERRABLE -------->
+-> NOT -+
There are two constraint-attributes:
Specifying NOT DEFERRABLE means that evaluation of the constraint
must take place when the INSERT, DELETE, or UPDATE statement
executes.
Specifying DEFERRABLE means that evaluation of the constraint can
take place at any later time. Unless otherwise specified, evaluation
of the constraint will take place as the COMMIT statement executes.
You can use the SET ALL CONSTRAINTS statement to have all constraints
evaluated earlier. See the SET ALL CONSTRAINTS statement for more
information.
If you are using the default SQLV40 dialect, the default
constraint-attribute is DEFERRABLE. When using this dialect, Rdb/VMS
displays a deprecated feature message for all constraints defined
without specification of one of the constraint attributes. The
default constraint-attribute may change in a future release. If you
are using the SQL92 dialect, the default is NOT DEFERRABLE.
alter col definition
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 typedomain namedefault valueadd col constraint
sql 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 database
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 delete the existing constraint and add a new column
constraint using the alter-col-definition clause 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 = -+-> char-data-types ---------------------------+--> +-> TINYINT --------------+-----+--------+-----+ +-> SMALLINT -------------+ +-> (n) -+ | +-> INTEGER --------------+ | +-> BIGINT ---------------+ | +-> LIST OF BYTE VARYING -+ | +-> DECIMAL -+-+-----------------------------+-+ +-> NUMERIC -+ +-> ( --> n -+--------+-> ) --+ | | +-> , n -+ | +-> FLOAT -+--------+--------------------------+ | +-> (n) -+ | +-> REAL --------------------------------------+ +-> DOUBLE PRECISION --------------------------+ +-> date-time-data-types ----------------------+
Additional information available:
char data types
char-data-types = -+-> CHAR +--------+-+-------------------------------------+-+-> | +-> (n) -+ +-> CHARACTER SET character-set-name -+ | +-> NCHAR ---------+-+--------+------------------------------+ +-> NATIONAL CHAR -+ +-> (n) -+ | +-> VARCHAR (n) -----+-------------------------------------+-+ | +-> CHARACTER SET character-set-name -+ | +-> NCHAR VARYING ----------+------+---------+---------------+ +-> NATIONAL CHAR VARYING --+ +-> (n) --+ | +-> LONG VARCHAR -------------------------------------------+ A charcter-set-name is a valid character set for database object names.
domain name
The name of a domain created in a CREATE DOMAIN statement. SQL gives the column the data type specified in the domain.
default value
default-value =
DEFAULT --+-->literal -----------+->
+-->USER -------------+
+-->NULL -------------+
+-->CURRENT_DATE -----+
+-->CURRENT_TIME -----+
+-->CURRENT_TIMESTAMP -+
Additional information available:
USERNULLCURRENT_DATECURRENT_TIMECURRENT_TIMESTAMP
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 (visually 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_DATE
DATE data type value containing year, month, and day for date 'today'.
CURRENT_TIME
TIME data type value containing hour, minute, and second for time 'now'.
CURRENT_TIMESTAMP
TIMESTAMP data type value containing year, month, and day for date 'today' and hour, minute, and second for time 'now' currently defined in Rdb/VMS.
add col constraint
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.
sql and dtr clause
sql-and-dtr-clause =
-+-> QUERY HEADER IS -+> quoted-string --+-----------------+->
| +------ / <--------+ |
+-> EDIT STRING IS quoted-string -------------------------+
| |
+-> QUERY NAME FOR -+-> DTR --------+-> IS quoted-string -+
| +-> DATATRIEVE -+ |
+-> DEFAULT VALUE FOR -+-> DTR --------+-> IS literal ----+
+-> DATATRIEVE -+
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.
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.