Common directives for DB2

Source: Internet
Author: User
Tags create index db2 db2 connect create database

Note: Uppercase is fixed, lowercase according to their actual situation

First go to command window, win+r---> Input db2cmd DB2

1. Deleting a database

Uncatalog db db_name--db_name database name

2. Create a new database

CREATE DATABASE db_name USING codeset Utf-8 TERRITORY cn PAGESIZE 8 K

3. View the database

LIST DB DIRECTORY

4. Connect to the database

CONNECT to db_name USER username USING password

5. Disconnecting database connections

DB2 CONNECT RESET

6. Create a table

CREATE TABLE table_name (username varchar (), password varchar (30))

7. Save

COMMIT

8. View the table

LIST TABLES

9. View table Structure

DESCRIBE TABLE table_name

10. Inserting data

INSERT into table_name VALUES (' username ', ' password '), (' Zhang ', ' 123456 ')

11. Querying data

SELECT * FROM table_name

12. Data Update

UPDATE table_name SET username = ' uname ' WHERE password = ' password '

13. Delete Data

DELETE from table_name WHERE username = ' uname '

14. Create an index

CREATE INDEX index_name on tablename (column)--column as a field in the table

15. View Index

DESCRIBE INDEXES for TABLE table_name

16. Deleting a database definition file

(1) db2look-d db_name-z table_name-e-o file_name.sql

(2) db2look-d db_name-e-O file_name.sql

Note that this statement is executed in the cmd window, not db2cmd

17. Executing the database definition file

Step: Enter Db2cmd under the current CMD Command window of the file, connect to the database,

DB2-TVF file_name.sql > File_name.log

18. Get DB Instance Parameters

DB2 GET DBM CFG

19. Modifying DB Instance Parameters

DB2 UPDATE DBM CFG USING param value

such as modifying the port number: DB2 UPDATE DBM CFG USING SVCENAME 60000

20. Get Database parameters

DB2 GET DB for Db_name

21. Changing Database Parameters

DB2 UPDATE DB CFG USING param value

22. Get the database environment variables

Db2set

23. Modify the database environment variables

Db2set param value

24. Export tool

DB2 EXPORT to File_name.del of del SELECT * FROM table_name

  

Common directives for DB2

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.