RDB/VMS SQL ATTACH — VMS RDB_4.1_M
ATTACH ───┬─> attach-string-literal ────┬─> typebox (;) ├─> attach-parameter ─────────┤ └─> attach-parameter-marker ──┘ attach-string-literal = ──> typebox (') ──> attach-expression ─> typebox (') ───>
Additional information available:
More Informationattach expression
More Information
Specifies the name of a database and the source of the data definitions to be accessed by interactive SQL or by a program at run time. Makes the specified database part of the database environment, so that you can refer to that database in subsequent CONNECT statements. The database environment is the set of all databases with unique aliases in an application. The ATTACH statement lets you add new databases at run time: it has no affect on the compilation environment. To specify the SQL environment for compilation, use the DECLARE ALIAS statement. If you do not declare any database, SQL declares the database specified in the logical name SQL$DATABASE as the default database by filename. See the Help topic on default_database for more information.
attach expression
attach-expression =
─────┬────────────────┬──────┐
└─>
A
L
I
A
S alias ─┘ │
┌────────────────────────────┘
└─┬─>
F
I
L
E
N
A
M
E ─> file-spec ─┬───────────┐
└─>
P
A
T
H
N
A
M
E ─> path-name ─┘ │
┌────────────────────────────────────────┘
└┬─────────────────────>───────────────┬─┐
└─>
D
B
K
E
Y typebox (S)typebox (C)typebox (O)typebox (P)typebox (E) typebox (I)typebox (S) ─┬──>
A
T
T
A
C
H ─────┬┘ │
└─>
T
R
A
N
S
A
C
T
I
O
N ─┘ │
┌────────────────────────────────────────┘
└─┬─────────────────────┬──┐
└─> database options ─┘ │
┌──────────────────────────┘
└─┬────────────────────────────┬───>
└─>
M
U
L
T
I
S
C
H
E
M
A
I
S ─┬─>
O
N ──┤
└─>
O
F
F ─┘
Additional information available:
FILENAMEPATHNAMEDBKEY_SCOPE_ISMULTISCHEMA_IS_ONMULTISCHEMA_IS_OFF
More InformationExamplesaliasDatabase options
More Information
The attach expression is a character string literal that specifies the database environment for the connection. The following example attaches the database PERSONNEL in the default directory to the default connection and declares the alias Q4_PAYROLL for that database. SQL> ATTACH 'ALIAS Q4_PAYROLL FILENAME PERSONNEL RDBVMS031'; SQL>
Examples
The following example attaches the database defined by the file
specification DISK2:[DEPT3]PERSONNEL to the default connection and
declares the alias PERS_ALIAS for that database.
SQL> ATTACH 'ALIAS PERS_ALIAS FILENAME DISK2:[DEPT3]PERSONNEL';
SQL> SHOW DATABASES;
Alias PERS_ALIAS:
Rdb/VMS database in file DISK2:[DEPT3]PERSONNEL
The following example attaches the database PERSONNEL_NH in the
current default directory to the default connection and gives that
database the default alias.
SQL> ATTACH 'FILENAME PERSONNEL_NH';
SQL> SHOW DATABASES;
Default alias:
Rdb/VMS database in file PERSONNEL_NH
alias
An alias is a name for a particular attachment to a database. Explicitly specifying an alias lets your program or interactive SQL statements refer to more than one database. Once specified, you must use the alias when referring to the database in subsequent SQL statements (unless those statements are within a CREATE DATABASE or CREATE SCHEMA statement). You must use an alias when you declare more than one database. DIGITAL proprietary database languages (such as RDO in Rdb/VMS) use the term database handle instead of alias.
FILENAME
FILENAME and PATHNAME both identify the database root file associated with the database. If you specify a data dictionary path name, the pathname indirectly specifies the root file.
PATHNAME
FILENAME and PATHNAME both identify the database root file associated
with the database. If you specify a data dictionary path name, the
pathname indirectly specifies the root file.
The following example uses the data dictionary definition with the
pathname CDD$DEFAULT.DEPT3.PERSONNEL to invoke the PERSONNEL to the
default connection and declares the alias PERS_ALIAS for that
database.
SQL> ATTACH 'ALIAS DICT_PERS PATHNAME CDD$DEFAULT.DEPT3.PERSONNEL';
SQL> SHOW DATABASES;
Alias DICT_PERS:
data dictionary pathname is DISK01:[CDDPLUS]DEPT3.PERSONNEL;1
Rdb/VMS database in file DISK02:[CORPORATE.DEPT3]PERSONNEL.RDB;
SQL>
DBKEY_SCOPE_IS
Controls when the database key of an erased record may be used again by SQL. The default is DBKEY SCOPE IS TRANSACTION, which means that SQL can reuse the database key of a deleted table row as soon you commit the transaction that deleted the original row and disconnect the connection. For more information, type HELP DBKEY.
Database options
The database options specify types of supported databases that your application can access. Specifying database options in the ATTACH statement overrides the default established in the precompiler or module language command line.
MULTISCHEMA_IS_ON
Enables multischema naming for the duration of the database attachment.
MULTISCHEMA_IS_OFF
Disables multischema naming for the duration of the database attachment. Multischema naming is disabled by default.