Operations and maintenance personnel DB2 daily operation commands

Source: Internet
Author: User
Tags db2 db2 client db2 connect db2 connect to db2 describe table

1. See which libraries the database server has

DB2 List DB Directory


2. Connect to the database

DB2 Connect to DBNAME (database name)


If you are connecting to a remote DB2 client, you need to enter a user name and password

DB2 Connect to DBNAME (database name) user USERNAME (user name) using PASSWD (password)


3. View DB2 service occupancy port

DB2 Get DB CFG | grep TCP


In general, the DB2 service occupies a port of 50000, confirming that you can use Netstat-an | GREP:50, to confirm the port starting with 50, if there is a large number of 50000 or 55000 ports interacting with other hosts, then the port is DB2 occupied port


DB2 Get DB CFG view data path configuration


4, view the information of the table

DB2 describe table TABLENAME (table name)


5. Export Data

DB2 "Export To/path/to/filenae (exported file name) of del select * from TABLENAME (table name)";


6. Import data

DB2 "Import from/path/to/filename (file importing data) of Del INSERT into TABLENAME (table name)";


7. Query data

SELECT * from TABLENAME (table name) where Mer_shop_name (query condition) like '% Pizza Hut% '

% Pizza Hut% for fuzzy query, content has Pizza Hut field that matches


SELECT * from TABLENAME (table name) where Mer_shop_name (query field) = Pizza Hut

= indicates exact match


8. Comprehensive inquiry

Select COUNT (1) from TABLENAME (table name 1) where order_id (query field) in (select order_id from TABLENAME (table name 2) where Pay_way (query field) in (' 1 ', ' 4 ', ' 5 ')) and Crt_time (query field) like ' 2016-12-28% '


9. Update data

Update TABLENAME (table name) set Mobile (query condition: mobile number) = ' 123456789 ' where user_id (query condition: User id) = 123456789;


10, query the first few rows of data

Search 2017 year ago 10 data

SELECT * from TABLENAME (table name) where Crt_time (query condition: creation time) like '%2017% ' fetch first ten rows only



This article is from the "Xiaoxiaozhou" blog, make sure to keep this source http://xiaoxiaozhou.blog.51cto.com/4681537/1953082

Operations and maintenance personnel DB2 daily operation commands

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.