Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

Format

More

Examples

RDB/VMS Relational Database Operator DELETE_RELATION — VMS RDB_4.1A

 Deletes one or more relation definitions and all associated
 relation-specific constraints.  When the DELETE RELATION statement
 executes, Rdb/VMS deletes the relation definition, the storage map
 (if one exists), the constraints associated with the relation
 definition, and the data stored in that relation from the physical
 database.  If you invoke the database using the PATHNAME argument,
 Rdb/VMS also deletes the relation definition from the CDD$DATABASE
 definition of the database in the data dictionary.

 Example:

      DELETE RELATION COLLEGES.

Additional information available:

FormatMoreExamples

Format

 DELETE RELATION ───┬────> relation-name ────┬─────> .
                    └─────<───── , <─────────┘

 relation-name   The name of the relation definition you want to
                 delete.

More

 You must have the Rdb/VMS DELETE privilege to a relation to delete
 the relation with the DELETE RELATION statement.

 If the database is created with the DICTIONARY IS REQUIRED option,
 you must invoke the database by path name, rather than file name,
 before you issue this statement.

 You cannot delete a relation when there are other active transactions
 involving the relation.  That is, you must have EXCLUSIVE access to
 the relation.

 If a view definition refers to a relation you want to delete, you
 must delete that view definition before you delete the relation.

 If a constraint in the database references a relation, you cannot
 delete that relation until you delete the constraint that references
 the relation.

 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.

 Other users are allowed to be attached to the database when you issue
 the DELETE RELATION statement.

Examples


 Example 1

 Delete a single relation definition:

 RDO> INVOKE DATABASE PATHNAME "PERSONNEL"
 RDO> DELETE RELATION COLLEGES.
 RDO> COMMIT

 This statement deletes the definition for COLLEGES from the database
 file for PERSONNEL and from the data dictionary.


 Example 2

 Delete more than one relation definition:

 RDO> INVOKE DATABASE PATHNAME "PERSONNEL"
 RDO> DELETE RELATION DEGREES, COLLEGES.
 RDO> COMMIT

 This statement deletes both DEGREES and COLLEGES from the database
 file for PERSONNEL and from the data dictionary.


 Example 3

 Delete a single relation and its associated relation-specific
 constraints from the database.  In this case, to delete the COLLEGES
 relation, it is necessary first to delete the DEGREES relation and
 the COLLEGE_CODE_CASCADE_UPDATE trigger because the COLLEGES relation
 has constraints that depend on them.

 RDO> INVOKE DATABASE PATHNAME "PERSONNEL"
 RDO> DELETE RELATION COLLEGES.
 %RDB-E-NO_META_UPDATE, metadata update failed
 -RDMS-F-CONEXI, relation COLLEGES is referenced in constraint
 DEGREES_FOREIGN2
 -RDMS-F-RELNOTDEL, relation COLLEGES has not been deleted
 RDO> DELETE CONSTRAINT DEGREES_FOREIGN2.
 %RDB-E-NO_META_UPDATE, metadata update failed
 -RDMS-F-CONDELVIAREL, constraint DEGREES_FOREIGN2 can only be
 deleted by changing or deleting relation DEGREES
 RDO> DELETE RELATION DEGREES.
 RDO> delete relation colleges.
 %RDB-E-NO_META_UPDATE, metadata update failed
 -RDMS-F-TRGEXI, relation COLLEGES is referenced in
 trigger COLLEGE_CODE_CASCADE_UPDATE
 -RDMS-F-RELNOTDEL, relation COLLEGES has not been deleted
 RDO> DELETE TRIGGER COLLEGE_CODE_CASCADE_UPDATE.
 RDO> DELETE RELATION COLLEGES.
 RDO> COMMIT

 This statement deletes the definition for COLLEGES from the database
 file for PERSONNEL and from the data dictionary.


 Example 4

 The following example shows that when a database is invoked by
 pathname and a database relation based on a global record in the
 dictionary is deleted, the relation 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 record
 in the dictionary is not deleted.

 The example also 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.
 The global definition of the field in the dictionary is not deleted,
 however:

 $ 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> !
 CDO> ! Define the global record RECORD_1 in the dictionary:
 CDO> DEFINE RECORD RECORD_1.
 cont> FIELD_1.
 cont> END RECORD_1 RECORD.
 CDO> DIRECTORY
  Directory RDO_USER:[RICH.DICT]
 CDD$PROTOCOLS                                    DIRECTORY
 CDD$RDB_SYSTEM_METADATA                          DIRECTORY
 FIELD_1;1                                        FIELD
 RECORD_1;1                                       RECORD
 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
 RECORD_1;1                                       RECORD
 CDO> EXIT
 $
 $ ! Invoke the database by pathname and define FIELD_1 and
 $ ! RECORD_1 in the database, using the dictionary definition
 $ ! of FIELD_1 and RECORD_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> DEFINE RELATION RECORD_1
 cont> FROM PATHNAME RDO_USER:[RICH.DICT]RECORD_1.
 RDO> !
 RDO> SHOW RELATION RECORD_1
      RECORD_1
    CDD pathname:        RDO_USER:[RICH.DICT]RECORD_1;1
 RDO> !
 RDO> ! Commit the definition of FIELD_1 and RECORD_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 and RECORD_1 definitions
 CDO> ! are part of the CDD$DATABASE definition for
 CDO> ! 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)
            .
            .
            .
 |   |   |   Contains CDD$RDB_DATA_ELEMENT
 |   |   |   |   FIELD_1                         (Type : CDD$DATA_ELEMENT)
 |   |   |   |   |   CDD$DATA_ELEMENT_DATATYPE       14
 |   |   |   |   |   CDD$DATA_ELEMENT_LENGTH         7
            .
            .
            .
 |   |   |   Contains CDD$RDB_DATA_AGGREGATE
 |   |   |   |   RECORD_1                        (Type : CDD$DATA_AGGREGATE)
 |   |   |   |   |   Contains CDD$DATA_AGGREGATE_CONTAINS
 |   |   |   |   |   |   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
 $ ! and RECORD_1 definitions from the database (this also deletes
 $ ! the FIELD_1 and RECORD_1 definitions 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 RELATION RECORD_1.
 RDO> !
 RDO> DELETE FIELD FIELD_1.
 RDO> !
 RDO> ! The definitions of FIELD_1 and RECORD_1 no longer exist in
 RDO> ! the physical database MY_DATABASE.RDB:
 RDO> SHOW FIELD FIELD_1
  No Fields Found
 RDO> !
 RDO> SHOW RELATION RECORD_1
  No Relations 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 definitions of FIELD_1 and RECORD_1 still
 CDO> ! exist in 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
 RECORD_1;1                                       RECORD
 CDO> !
 CDO> ! Although the global definitions of FIELD_1 and RECORD_1 still
 CDO> ! exist in the dictionary, the definitions of FIELD_1 and
 CDO> ! RECORD_1 no longer exist in the the CDD$DATABASE definition
 CDO> ! 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

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026