Common DB2 commands

Source: Internet
Author: User
Tags db2 connect db2 connect to

Common DB2 commands
I. Common commands

Command Description
Db2start Start the current instance
Db2stop Stop current instance
Db2stop force Force stop the current instance
Db2icrt Create an instance
Db2idrop Delete An Instance
Db2ilist List instances
Db2 get instance Show current instance
Set db2instance = XXX Switch to XXX instance
Db2 list db directory List Databases
Db2 create db [dbname] Create a database
Db2 drop db [dbname] Delete Database
Db2 list applications View All database connections
Db2 get snapshot for locks on [dbname] Check the deadlock Process
Db2 force application (1, 123) Forcibly disconnect a database with an application handle of 123
Db2 force applications all Force disconnect all databases
Db2 connect to [dbname] Connect to database
Db2 connect to [dbname] user [name] using [pwd] Connect to the database with a specified user
Db2 get dbm cfg Obtain the Database Manager Configuration File
Db2 get db cfg for [dbname] Obtain the Database Configuration File
Db2 connect reset Disconnect the database but do not exit the clp (command line processor)
Db2 terminate Disconnect the database and exit the clp (command line processor)
2. Catalog (add the remote database to the local for access) and reverse catalog 1. catalog node db2 catalog tcpip node [node_name] remote [ip] server [port] remote_instance [instance_name] ostype win/linux2. catalog the database to the db2 catalog db [dbname] as [alias] at node [node_name] authentication server where [node_name] is the node name, it cannot be repeated. [instance_name] is the Instance name. For convenience, the [ip] [port] is the IP port, and the win/linux is the system type, [dbname] is the name of the remote database, and [alias] is the name of the database used for local access after being stored locally. Generally, the name is the same as that of the remote database. 3. uncatalog db2 uncatalog db [dbname] db2 uncatalog node [node_name] 3. Execute the script db2-tvf script on the command line processor. SQL-z script. in the preceding command,-t indicates that the statement uses the default statement Terminator;-v indicates that the statement uses the lengthy mode, in this way, DB2 displays the information of each command being executed.-f indicates that the script file-z indicates that the subsequent information record file is used to record the screen output, for future analysis convenience (optional, but this option is recommended) If the statement Terminator is not a semicolon, you can use the-d option combined with-t to declare other terminologies as follows-td! As shown in: db2-td! -Vf script. SQL-z script. log 4. Import, export, and export: db2 export to test. del of del select * from test import: db2 import from test. del of del insert into testdb2 load from test. del of del insert into test batch export: db2move [dbname] export-u username-p password batch import: db2move [dbname] import-u username-p passworddb2move [dbname] load-u username-p password has many import and export operations. These are common usage. The simple difference between imported import and load is that import writes logs, which is slow. The imported files must be on the client machine. load does not write logs, which is efficient, the imported and read files must be on the server.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.