RDB/VMS Relational Database Operator DELETE_FIELD — VMS RDB_4.1_M
Deletes one or more field definitions. When the DELETE FIELD
statement executes, Rdb/VMS deletes the field definition from the
physical database. If you invoke the database using the PATHNAME
argument, Rdb/VMS also deletes the field definition from the
CDD$DATABASE definition of the database in the data dictionary. You
can delete any named field, whether it was defined with a DEFINE
FIELD statement or with a DEFINE RELATION statement. However, you
cannot delete a field that is referred to in the definition of a
relation, index, or constraint:
Example:
DELETE FIELD POSTAL_CODE.
Additional information available:
More
o You must have the Rdb/VMS DELETE privilege for a field to delete
the field with the DELETE FIELD statement.
o If you want to delete a field that is part of a relation
definition, you must use the CHANGE RELATION statement to delete
the field from the relation definition, or you must delete the
entire relation.
o If you want to delete a field that is referred to in a constraint
or index definition, you must first delete the constraint or
index.
o You cannot delete a field definition unless you have invoked the
database that includes the field.
o You can delete a field definition even when there are active
users. Deleting a field definition will not affect active users
until they exit their session and invoke the database the next
time. By default, a database can be opened automatically (that
is, by any user who invokes the database and executes a data
manipulation language statement). If the database was modified
so that it must be manually opened, the RMU/OPEN command must be
used to open it.
o You must execute this statement in a read/write transaction. If
there is no active transaction and you issue this statement,
Rdb/VMS starts a read/write transaction implicitly.
Format
DELETE FIELD ───┬───> field-name ────┬───> . └────<──── , ────<───┘ field-name The name of the field whose definition you want to delete.
Examples
Example 1
Delete a single field definition:
RDO> INVOKE DATABASE PATHNAME 'PERSONNEL'
RDO> START_TRANSACTION READ_WRITE
RDO> DELETE FIELD TEMP_NUM.
RDO> COMMIT
This sequence deletes the field definition from the physical database
and the data dictionary.
Example 2
Delete more than one field definition:
RDO> INVOKE DATABASE PATHNAME 'PERSONNEL'
RDO> START_TRANSACTION READ_WRITE
RDO> DELETE FIELD TEMP_NUM, MONEY.
RDO> COMMIT
This sequence deletes the definitions for the TEMP_NUM and MONEY
fields from the physical database and the data dictionary.
Example 3
Delete a field from a relation:
RDO> INVOKE DATABASE PATHNAME 'PERSONNEL'
RDO> START_TRANSACTION READ_WRITE
RDO> DELETE FIELD STATUS_NAME.
%RDO-W-NOCDDUPDAT, database invoked by filename, the CDD will not be
updated
%RDB-E-NO_META_UPDATE, metadata update failed
%RDMS-F-RELEXI, field STATUS_NAME is used in relation, WORK_STATUS
-RDMS-F-FLDNOTDEL, field STATUS_NAME has not been deleted
RDO> CHANGE RELATION WORK_STATUS.
cont> DELETE STATUS_NAME.
cont> END.
RDO> DELETE FIELD STATUS_NAME.
RDO> COMMIT
If a field is used in a relation, you need to perform two operations
to delete it:
o Change the relation by deleting the field.
o Delete the global field definition.
Example 4
The following example shows that when a database is invoked by
pathname and a database field based on a global field in the
dictionary is deleted, the field is deleted from both the physical
database and from the CDD$DATABASE definition of the database in the
dictionary. Note, however, that the global definition of the field
in the dictionary is not deleted:
$ DICTIONARY OPERATOR
Welcome to CDO V1.3-2
The CDD/Plus V4.3-2 User Interface
Type HELP for help
CDO> SET DEFAULT CDD$DEFAULT
CDO> !
CDO> ! Define the global field FIELD_1 in the dictionary:
CDO> DEFINE FIELD FIELD_1
cont> DATATYPE IS TEXT SIZE IS 7.
CDO> DIRECTORY
Directory RDO_USER:[RICH.DICT]
CDD$PROTOCOLS DIRECTORY
CDD$RDB_SYSTEM_METADATA DIRECTORY
FIELD_1;1 FIELD
CDO> EXIT
$ RDO
RDO> ! Define the Rdb/VMS database MY_DATABASE.RDB, specifying the
RDO> ! pathname where the CDD$DATABASE definition of MY_DATABASE.RDB
RDO> ! will be stored:
RDO> DEFINE DATABASE RDO_USER:[RICH]MY_DATABASE
cont> IN RDO_USER:[RICH.DICT]MY_DATABASE.
RDO> COMMIT
%RDO-F-NO_TXNOUT, no transaction outstanding
RDO> FINISH
RDO> EXIT
$ !
$ ! Show that the CDD$DATABASE definition for the MY_DATABASE
$ ! database now exists in the data dictionary:
$ DICTIONARY OPERATOR
Welcome to CDO V1.3-2
The CDD/Plus V4.3-2 User Interface
Type HELP for help
CDO> SET DEFAULT CDD$DEFAULT
CDO> DIRECTORY
Directory RDO_USER:[RICH.DICT]
CDD$PROTOCOLS DIRECTORY
CDD$RDB_SYSTEM_METADATA DIRECTORY
FIELD_1;1 FIELD
MY_DATABASE;1 CDD$DATABASE
CDO> EXIT
$
$ ! Invoke the database by pathname and define FIELD_1 in the
$ ! database, using the dictionary definition of FIELD_1:
$ RDO
RDO> INVOKE DATABASE PATHNAME RDO_USER:[RICH.DICT]MY_DATABASE
RDO> !
RDO> DEFINE FIELD FIELD_1
cont> FROM PATHNAME RDO_USER:[RICH.DICT]FIELD_1.
RDO> !
RDO> SHOW FIELD FIELD_1
FIELD_1 text size is 7
CDD pathname: RDO_USER:[RICH.DICT]FIELD_1;1
RDO> !
RDO> ! Commit the definition of FIELD_1:
RDO> COMMIT
RDO> FINISH
RDO> EXIT
$ !
$ DICTIONARY OPERATOR
Welcome to CDO V1.3-2
The CDD/Plus V4.3-2 User Interface
Type HELP for help
CDO> ! Show that the FIELD_1 definition is part of the
CDO> ! CDD$DATABASE definition for MY_DATABASE.RDB in
CDO> ! the dictionary:
CDO> SHOW GENERIC CDD$DATABASE/FULL MY_DATABASE
Definition of MY_DATABASE (Type : CDD$DATABASE)
| Contains CDD$DATABASE_FILE
| | RDO_USER:[RICH]MY_DATABASE (Type : CDD$FILE)
| | | CDD$QUALIFIED_NAME RDO_USER:[RICH]MY_DATABASE.RDB;
| Contains CDD$DATABASE_SCHEMA
| | MY_DATABASE (Type : CDD$RDB_DATABASE)
.
.
.
| | | Contains CDD$RDB_DATA_ELEMENT
| | | | FIELD_1 (Type : CDD$DATA_ELEMENT)
| | | | | CDD$DATA_ELEMENT_DATATYPE 14
| | | | | CDD$DATA_ELEMENT_LENGTH 7
.
.
.
CDO> EXIT
$ !
$ ! Invoke MY_DATABASE.RDB by pathname and delete the FIELD_1
$ ! definition from the database (this also deletes the
$ ! FIELD_1 definition from the CDD$DATABASE definition
$ ! of MY_DATABASE.RDB in the dictionary):
RDO> INVOKE DATABASE PATHNAME RDO_USER:[RICH.DICT]MY_DATABASE
RDO> !
RDO> DELETE FIELD FIELD_1.
RDO> !
RDO> ! The definition of FIELD_1 no longer exists in the physical
RDO> ! database MY_DATABASE.RDB:
RDO> SHOW FIELD FIELD_1
No Fields Found
RDO> COMMIT
RDO> FINISH
RDO> EXIT
$ !
$ DICTIONARY OPERATOR
Welcome to CDO V1.3-2
The CDD/Plus V4.3-2 User Interface
Type HELP for help
CDO> ! The global definition of FIELD_1 still exists in
CDO> ! in the dictionary:
CDO> SET DEFAULT CDD$DEFAULT
CDO> DIRECTORY
Directory RDO_USER:[RICH.DICT]
CDD$PROTOCOLS DIRECTORY
CDD$RDB_SYSTEM_METADATA DIRECTORY
FIELD_1;1 FIELD
MY_DATABASE;1 CDD$DATABASE
CDO> !
CDO> ! Although the global definition of FIELD_1 still exists in the
CDO> ! dictionary, the definition of FIELD_1 no longer exists in the
CDO> ! the CDD$DATABASE definition of MY_DATABASE.RDB in the dictionary:
CDO> SHOW GENERIC CDD$DATABASE /FULL MY_DATABASE
Definition of MY_DATABASE (Type : CDD$DATABASE)
| Contains CDD$DATABASE_FILE
| | RDO_USER:[RICH]MY_DATABASE (Type : CDD$FILE)
| | | CDD$QUALIFIED_NAME RDO_USER:[RICH]MY_DATABASE.RDB;
| Contains CDD$DATABASE_SCHEMA
| | MY_DATABASE (Type : CDD$RDB_DATABASE)
.
.
.
CDO> EXIT