Operation commands in the db2 database
Common DB2 commands. For more information about using db2, see. The management Client no longer has a control center after v9.7, but uses the Data Studio Client. The license key is not applied during the installation of the DB2 database product. However, the following products do not activate CD, so their licenses will be automatically applied when these products are installed: DB2 Express-C and DB2 Connect Personal Edition. DB2 Personal Edition is also a special case. Although DB2 Personal Edition has activated CD, its license will be automatically applied when the product is installed.
PS:Before executing the command, you need to enter the DB2 account: su db2inst1
Change Password: Change the corresponding operating system password. In windows, you can change the db2admin password. in linux, you can change the db2inst1 password. The db2 database password is bound to the operating system, as you said, you only need to modify the user password on the operating system. You can change the password of the user on the operating system.
======================================== Experience is the most valuable ====== ==================================
1. Open the command line window
# Db2cmd
2. Open the Control Center
# Db2cmd db2cc
3. Open the command editor.
Db2cmd db2ce
===== Operation database commands ====
4. Start a database instance
======================================
26. Back up the database
# Db2 backup db
Note: You must disconnect the database before executing the preceding commands.
27. Online Database Backup
# Db2-v "backup database online to with 2 buffers buffer 1024 include logs without prompting"
28. Restore the database
# Db2 restore db
29. Online database recovery
# Db2 "restore db to logtarget without prompting"
# Db2 "rollforward db to end of logs and stop "...
30. Export data files
# Db2move export
[-Sn <mode name, usually db2admin>]
[-Tn <table names, separated by commas>]
31. import data files
# Db2move import
32. obtain information about the db2 database management configuration Environment
# Db2 get dbm cfg
33. obtain information about the management and configuration environment of a database in db2
# Db2 get db cfg
Or: Execute db2 get db cfg after connecting to a database
34. Change the size of db2 log Space
Note: The following command is used only for db2 on the developer's own machine to prevent the db2 database from using hard disk space excessively. If it is a server, the parameter needs to be modified.
# Db2 update db cfg for using logretain OFF logprimary 3 logsecond 2 logfilsiz 25600;
If the page size is 4 kb, the preceding command creates 3 MB log files, occupying MB of hard disk space. 25600 * 4KB = 102400KB.
35. Create a temporary tablespace
# DB2 create user temporary tablespace stmaspace pagesize 32 k managed by database using (FILE 'd: \ DB2_TAB \ STMASPACE. f1' 10000)
EXTENTSIZE 256
36. Obtain snapshot data of the Database Manager
# Db2-v get snapshot for dbm
37. Enter the itinerary number
# Db2 list applications show detail
========================================================== ==============
1. load data:
1. load with the default separator. The default value is ",".
Db2 "import from btpoper.txt of del insert into btpoper"
2. load with the specified separator "|"
Db2 "import from btpoper.txt of del modified by coldel | insert into btpoper"
Ii. Uninstall data:
1. unmount all data in a table
Db2 "export to btpoper.txt of del select * from btpoper"
Db2 "export to btpoper.txt of del modified by coldel | select * from btpoper"
2. unmount data from a table with conditions
Db2 "export to btpoper.txt of del select * from btpoper where brhid = '20140901 '"
Db2 "export to cmcode.txt of del select * from cmcodewhere codtp = '01 '"
Db2 "export to cmkcode.txt of del modified by coldel | select * from cmkcode where codtp = '01 '"
Iii. query data structures and data:
Db2 "select * from btpoper"
Db2 "select * from btpoper where brhid = '000000' and oprid = '000000 '"
Db2 "select oprid, oprnm, brhid, passwd from btpoper"
4. Delete table data:
Db2 "delete from btpoper"
Db2 "delete from btpoper where brhid = '000000' or brhid = '000000 '"
5. Modify Table data:
Db2 "update svmmst set prtlines = 0 where brhid = '000000' and jobtp = '02 '"
Db2 "update svmmst set prtlines = 0 where jobtp = '02 'or jobtp = '03 '"
6. Database Connection
Db2 connect to btpdbs
7. Clear database connections
Db2 connect reset disconnects the database
Db2 terminate disconnect Database
Db2 force applications all disconnect all databases
8. Back up databases
1. db2 backup db btpdbs
2. db2move btpdbs export
Db2look-d btpdbs-e-x [-a]-o crttbl. SQL
9. Restore the database
1. db2 restore db btpdbs without rolling forward