SQL$HELP_OLD72.HLB  —  CONNECT  Examples
    Example 1: Creating a default connection and one other connection

    The following example shows how a user attaches to one database
    with two different connections: the default connection and the
    named connection TEST.

    SQL> attach 'alias MIA1 filename MIA_CHAR_SET';
    SQL> connect to 'alias MIA1 filename MIA_CHAR_SET' as 'TEST';
    SQL> show connections;
            RDB$DEFAULT_CONNECTION
    ->      TEST
    SQL> show connections TEST;
    Connection: TEST
    Default alias is RDB$DBHANDLE
    Default catalog name is RDB$CATALOG
    Default schema name is SMITH
    Dialect: SQLV40
    Default character unit: OCTETS
    Keyword Rules: SQLV40
    View Rules: SQLV40
    Default DATE type: DATE VMS
    Quoting Rules: SQLV40
    Optimization Level: DEFAULT
    Hold Cursors default: WITH HOLD PRESERVE NONE
    Quiet commit mode: OFF
    Compound transactions mode: EXTERNAL
    Default character set is DEC_MCS
    National character set is DEC_MCS
    Identifier character set is DEC_MCS
    Literal character set is DEC_MCS
    Display character set is UNSPECIFIED

    Alias MIA1:
            Identifier character set is DEC_KANJI
            Default character set is DEC_KANJI
            National character set is KANJI

    Example 2: Creating a default connection and two other
    connections

    The following example attaches to three databases: personnel_
    northwest, personnel_northeast, and personnel_southeast. (By
    not specifying an alias for personnel_northwest, it is assigned
    the default alias.) Several connections are established,
    including EAST_COAST, which includes both personnel_northeast
    and personnel_southeast.

    Use the SHOW DATABASE statement to see the changes to the
    database.

    SQL> --
    SQL> -- Attach to the personnel_northwest and personnel_northeast databases.
    SQL> -- Personnel_northwest has the default alias, so personnel_northeast
    SQL> -- requires an alias.
    SQL> -- All of the attached databases comprise the default connection.
    SQL> --
    SQL> ATTACH 'FILENAME personnel_northwest';
    SQL> ATTACH 'ALIAS NORTHEAST FILENAME personnel_northeast';
    SQL> --
    SQL> -- Add the personnel_southeast database.
    SQL> --
    SQL> ATTACH 'ALIAS SOUTHEAST FILENAME personnel_southeast';
    SQL> --
    SQL> -- Connect to personnel_southeast.  CONNECT does an
    SQL> -- implicit SET CONNECT to the newly created connection.
    SQL> --
    SQL> CONNECT TO 'ALIAS SOUTHEAST FILENAME personnel_southeast'
    cont>     AS 'SOUTHEAST_CONNECTION';
    SQL> --
    SQL> -- Connect to both personnel_southeast and personnel_northeast as
    SQL> -- EAST_COAST connection. SQL replaces the current connection to
    SQL> -- the personnel_southeast database with the EAST_COAST connection
    SQL> -- when you issue the CONNECT statement. You now have two different
    SQL> -- connections that include personnel_southeast.
    SQL> --
    SQL> CONNECT TO 'ALIAS NORTHEAST FILENAME personnel_northeast,
    cont>     ALIAS SOUTHEAST FILENAME personnel_southeast'
    cont>     AS 'EAST_COAST';
    SQL> --
    SQL> -- The DEFAULT connection still includes all of the attached databases.
    SQL> --
    SQL> SET CONNECT DEFAULT;
    SQL> --
    SQL> -- DISCONNECT releases the connection name EAST_COAST, but
    SQL> -- does not detach from the EAST_COAST databases because
    SQL> -- they are also part of the default connection.
    SQL> --
    SQL> DISCONNECT 'EAST_COAST';
    SQL> --
    SQL> SET CONNECT 'EAST_COAST';
    %SQL-F-NOSUCHCON, There is not an active connection by that name

    SQL> --
    SQL> -- If you disconnect from the default connection, and have no other
    SQL> -- current connections, you are longer be attached to any databases.
    SQL> --
    SQL> DISCONNECT DEFAULT;
    SQL> SHOW DATABASES;
    %SQL-F-ERRATTDEF, Could not use database file specified by SQL$DATABASE
    -RDB-E-BAD_DB_FORMAT, SQL$DATABASE does not reference a database known to Rdb
    -RMS-E-FNF, file not found
Close Help