DB2 Version 9.7 for Linux, UNIX, and Windows

ATTACH command

Enables an application to specify the instance at which instance-level commands (CREATE DATABASE and FORCE APPLICATION, for example) are to be executed. This instance can be the current instance, another instance on the same workstation, or an instance on a remote workstation.

Authorization

None

Required connection

None. This command establishes an instance attachment.

Command syntax

Read syntax diagramSkip visual syntax diagram
>>-ATTACH--+--------------+------------------------------------->
           '-TO--nodename-'   

>--+---------------------------------------------------------------------------+-><
   '-USER--username--+-------------------------------------------------------+-'   
                     +-USING--password--+----------------------------------+-+     
                     |                  '-NEW--password--CONFIRM--password-' |     
                     '-CHANGE PASSWORD---------------------------------------'     

Command parameters

TO nodename
Alias of the instance to which the user wants to attach. This instance must have a matching entry in the local node directory. The only exception to this is the local instance (as specified by the DB2INSTANCE environment variable) which can be specified as the object of an attach, but which cannot be used as a node name in the node directory.
USER username
Specifies the authentication identifier. When attaching to a DB2® database instance on a Windows operating system, the user name can be specified in a format compatible with Microsoft Security Account Manager (SAM). The qualifier must be a flat-style (NetBIOS-like) name, which has a maximum length of 15 characters. For example, domainname\username.
USING password
Specifies the password for the user name. If a user name is specified, but a password is not specified, the user is prompted for the current password. The password is not displayed at entry.
NEW password
Specifies the new password that is to be assigned to the user name. The system on which the password will be changed depends on how user authentication has been set up. The DB2 database system provides support for changing passwords on AIX®, Linux and Windows operating systems, and supports up to 255 characters for your own written plugins. See Password rules for additional information about passwords.
CONFIRM password
A string that must be identical to the new password. This parameter is used to catch entry errors.
CHANGE PASSWORD
If this option is specified, the user is prompted for the current password, a new password, and for confirmation of the new password. Passwords are not displayed at entry.

Examples

Catalog two remote nodes:
   db2 catalog tcpip node node1 remote freedom server server1
   db2 catalog tcpip node node2 remote flash server server1
Attach to the first node, force all users, and then detach:
   db2 attach to node1
   db2 force application all
   db2 detach
Attach to the second node, and see who is on:
   db2 attach to node2
   db2 list applications
After the command returns agent IDs 1, 2 and 3, force 1 and 3, and then detach:
   db2 force application (1, 3)
   db2 detach
Attach to the current instance (not necessary, will be implicit), force all users, then detach (AIX only):
   db2 attach to $DB2INSTANCE
   db2 force application all
   db2 detach

Usage notes

If nodename is omitted from the command, information about the current state of attachment is returned.

If ATTACH has not been executed, instance-level commands are executed against the current instance, specified by the DB2INSTANCE environment variable.