DB2 commands in Linux

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

DB2 database commands

1. Start the database

Db2start

2. Stop the database

Db2stop

3. Connect to the database

Db2 connect to o_yd user db2 using pwd

4. Read Database Management Program Configuration

Db2 get dbm cfg

5. Write Database Management Program Configuration

Db2 update dbm cfg using parameter name parameter value

6. Read Database Configuration

Db2 connect to o_yd user db2 using pwd

Db2 get db cfg for o_yd

7. Write Database Configuration

Db2 connect to o_yd user db2 using pwd

Db2 update db cfg for o_yd using parameter name parameter value

8. Close all application connections

Db2 force application all

Db2 force application ID1, ID2, Idn MODE ASYNC

(Db2 list application for db o_yd show detail)

9. Back up the database

Db2 force application all

Db2 backup db o_yd to d:

(Db2 initialize tape on \. \ tape0)

(Db2 rewind tape on \. \ tape0)

Db2 backup db o_yd to \. \ tape0

10. Restore the database

Db2 restore db o_yd from d: to d:

Db2 restore db o_yd from \. \ tape0 to d:

11. Bind a stored procedure

Db2 connect to o_yd user db2 using pwd

Db2 bind c: \ dfplus. bnd

Copy the stored procedure to the C: \ sqllib \ function directory on the server.

12. Sort the table

Db2 connect to o_yd user db2 using pwd

Db2 reorg table ydd

Db2 runstats on table ydd with distribution and indexes all

13. Export table data

Db2 export to c: \ dftz.txt of del select * from dftz

Db2 export to c: \ dftz. ixf of ixf select * from dftz

14. Import table data

Import from c: \ 123.txt of del insert into ylbx. czyxx

Db2 import to c: \ dftz.txt of del commitcount 5000 messages c: \ dftz. msg insert into dftz

Db2 import to c: \ dftz. ixf of ixf commitcount 5000 messages c: \ dftz. msg insert into dftz

Db2 import to c: \ dftz. ixf of ixf commitcount 5000 insert into dftz

Db2 import to c: \ dftz. ixf of ixf commitcount 5000 insert_update into dftz

Db2 import to c: \ dftz. ixf of ixf commitcount 5000 replace into dftz

Db2 import to c: \ dftz. ixf of ixf commitcount 5000 create into dftz (IXF only)

Db2 import to c: \ dftz. ixf of ixf commitcount 5000 replace_create into dftz (IXF only)

15. Execute a batch file

Db2-tf batch processing file name

(Use and end each command in the file)

16. automatically generate a batch file

Document: temp. SQL

Select 'runstats on table DB2. '| tabname |'

With distribution and detailed indexes all ;'

From syscat. tables where tabschema = 'db2 'and type = 'T ';

Db2-tf temp. SQL> runstats. SQL

17. automatically generate the table creation (View) Statement

On the server: C: \ sqllib \ misc directory

Db2 connect to o_yd user db2 using pwd

Db2look-d o_yd-u db2-e-p-c: \ o_yd.txt

18. Other commands

Grant dbadm on database to user bb

19 select * from czyxx fetch first 1 rows only

20db2look-d ylbx-u db2admin-w-asd-a-e-o a.txt 21. Show All Tables of the current user

List tables

22. list all system tables

List tables for system

23. view the table structure

Db2 describe select * from user. tables

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.