Sunday, January 17, 2010

Most Often Commands But V forget thesee...

When issuing the DB2 CLP commands from the OS command prompt on Linux/UNIX systems, it
may be necessary to put double quotes around the CLP command. For example, when issuing
db2 describe output select * from sales, you need to put double quotes around the
describe command, e.g. db2 “describe output select * from sales”. These double
quotes are necessary because the ‘*’ is a special OS command line character. The double quotes
will allow DB2 to parse the statement properly.

ACTIVATE DATABASE
Description: Activates the specified database and starts up all necessary database services, so that the database is available for connection and use by any application.

Authorization: sysadm/sysctrl/sysmaint
Windows/Linux/UNIX Examples
Example 1:
To activate database sample to eliminate any application time spent on database initialization:
activate database sample
Example 2:
To activate database sample with user ID db2user and password abc123:
activate database sample user db2user using abc123

Notes
• Databases initialized by ACTIVATE DATABASE can be shut down using the DEACTIVATE
DATABASE command.
• The application issuing the ACTIVATE DATABASE command cannot have an active database connection to any database.


ADD CONTACT
Description: Adds a contact to the contact list which can be either defined locally on the system or in a global list. Contacts are users to whom processes such as the Scheduler and Health Monitor send messages.

The setting of the Database Administration Server (DAS) contact_host

Configuration parameter determines whether the list is local or global.

Authorization: None
Windows/Linux/UNIX Examples

Example 1:
Add Mahesh as the contact person to receive event notifications via email at
dangm@ca.ibm.com:
add contact Mahesh type email address dangm@ca.ibm.com
Example 2:
Add Mahesh as the contact person to receive event notifications via page at Mahesh@page.com.
Include a description of the contact person.
add contact Mahesh type page address Mahesh@page.com description ‘DB2 Support for IBM’
Example 3:
Add Mahesh as the contact person to receive event notifications via page at Mahesh@page.com.
Specify the 250 character message-limit restriction on the paging service:
add contact Mahesh type page maximum page length 250 address Mahesh@page.com
Notes
The notification system uses the SMTP protocol to send the notification to the mail server specified by the DB2 Administration Server configuration parameter smtp_server.
It is the responsibility of the SMTP server to send the e-mail or call the pager.


ADD CONTACTGROUP

Description: Adds a new contact group to the list of groups defined on the local system.
A contact group is a list of users and groups to whom monitoring processes such as the Scheduler and Health Monitor can send messages.
Authorization: None
Windows/Linux/UNIX Examples
Example 1:
Create a new contact group “instance_monitor” and add Mahesh and Sylvia as contact members:
add contactgroup instance_monitor contact Mahesh, contact Sylvia
Example 2:
Create a new contact group “instance_monitor” and add Mahesh and Sylvia as contact members. Include a description of the group:
add contactgroup instance_monitor contact Mahesh, contact Sylvia description ‘Instance down monitor group’
Example 3:
Create a new contact group “instance_monitor” and add the group “dba_group” to it. Include a description of the group.

add contactgroup instance_monitor group dba_group description ‘Instance
down monitor group’

Notes
• Local execution only: this command cannot be used with a remote connection.
• Contact group name must be unique among the set of groups on the system.

ADD DBPARTITIONNUM

Description: Adds a new database partition server to the partitioned database environment. This command also creates a database partition for all databases on the new database partition server. The user can specify the source database partition server for the definitions of any system temporary table spaces to be created with the new database partition, or specify that no system temporary table spaces are to be created.

Authorization: sysadm/sysctrl
Windows/Linux/UNIX Examples
Example 1:
Using the following db2node.cfg:
0              ServerA              0
1              ServerA              1
2              ServerA              2

Example 1:
To add a fourth partition (node 3), set “export db2node=3”
add dbpartionnum
Example 2:
To add a fourth partition (node 3), you want the new partition’s system temporary table space to be the same as node 2. Set “export db2node=3”
add dbpartitionnum like dbpartitionnum 2
Example 3:
To add a fourth partition (node 3), you do not want system temporary table space containers to be created. Set “export db2node=3”
add dbpartitionnum without tablespaces

Notes
• This command must be issued from the database partition server that is being added.
• For compatibility with versions earlier than Version 8, use the keyword NODE instead of DBPARTITIONNUM.

ARCHIVE LOG

Description: Closes and truncates the active log file for a recoverable database. If user exit is enabled, an archive request is issued.
Authorization: sysadm/sysctrl/sysmaint/dbadm
Windows/Linux/UNIX Examples

Using the following db2node.cfg:
0              ServerA              0
1              ServerA              1
2              ServerA              2

Example 1:
You want to copy all log files for a sample database on all partitions to a development sample database at a particular timestamp. Truncate the logs at a particular time with:
archive log for database sample on all dbpartitionnums
Example 2:
The following command is the same as example 1.
Archive logs for database on all dbpartitionnums is the default.
archive log for database sample
Example 3:
To archive all log files for sample database on all partitions except partition two:
archive log for db sample on all dbpartitionnums except dbpartitionnum(2)
Example 4:
You want to archive all log files for sample database on partition 0 only.
archive log for db sample on dbpartitionnum (2)
Example 5:
The following command is the same as example 4.
archive log for db sample on all dbpartitionnums except dbpartitionnums(1 to 2)
Example 6:
You want to archive all logs files for sample database on partitions 0 and 2.
archive log for db sample on dbpartitionnums(0, 2)

Notes

•This command can only be executed when the invoking application or shell does not have a database connection to the specified database, otherwise sqlcode SQL1490N will be returned.
•This command can only be executed on a recoverable database; otherwise sqlcode SQL2417N will be returned.
•For compatibility with versions earlier than Version 8, use the keyword NODE instead of DBPARTITIONNUM.

ATTACH
Description: 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 may be the current instance, another instance on the same workstation, or an instance on a remote workstation.
Authorization: None
Windows/Linux/UNIX
Examples
Catalog two remote nodes: (See CATALOG TCPIP NODE command for information on cataloging remote nodes.)
catalog tcpip node node1 remote freedom server 50000
catalog tcpip node node2 remote flash server 50000
Example 1:
Attach to the first node, force all users, and then detach.
attach to node1
force application all
detach
Example 2:
Attach to the second node, and see who is on.
attach to node2
list applications
After the command returns agent IDs 1, 2 and 3, force 1 and 3, and then detach.
force application (1, 3)
detach
Example 3:
Attach to the current instance (not necessary, will be implicit), force all users, then detach (AIX only).
attach to $DB2INSTANCE
force application all
detach
Example 4:
Attach to instance db2inst1 using user ID user1 and password.
attach to db2inst1 user user1 using abc123
Example 5:
Attach to instance db2inst1 using user ID user1 and desire to change the password. You will be prompted with for the old password, a new password and a confirmation of the new password.
attach to db2inst1 user user1 change password
Example 6:
Attach to instance db2inst1 using user ID user1 and change the password to newpw1.
attach to db2inst1 user user1 using abc123 new newpw1 confirm newpw1
Notes
“VERIFY” parameter will transfer the backup image over the network before doing the
consistency check.

0 comments: