DB2 Common commands (1)

Source: Internet
Author: User
Tags db2 describe table

DB2 databaseApplication is very common for some beginners, theseCommandDaquan is the first thing to grasp. Next, I will not talk much about it. I will directly present you a list of commonly used DB2 commands.

I. Common commands

1. Create a database DB2_GCB

Create database DB2_GCB on g: ALIAS DB2_GCB

Using codeset gbk territory cn collate using system DFT_EXTENT_SZ 32

2. Connect to the database

Connect to sample1 user db2admin using 8301206

3. Create an alias

Create alias db2admin. tables for sysstat. tables;

Create alias DB2ADMIN. views for syscat. VIEWS

Create alias db2admin. columns for syscat. columns;

Create alias guest. columns for syscat. columns;

4. Create a table

Create table zjt_tables

(Select * from tables) definition only;

Create table zjt_views

(Select * from views) definition only;

5. Insert records

Insert into zjt_tables select * from tables;

Insert into zjt_views select * from views;

6. Create a view

Create view V_zjt_tables as select tabschema, tabname from zjt_tables;

7. Create a trigger

Create trigger zjt_tables_del

After delete on zjt_tables

REFERENCING OLD AS O

For each row mode DB2SQL

Insert into zjt_tables1 values (substr (o. tabschema,), substr (o. tabname ))

8. Create a unique index

Create unique index I _ztables_tabname

ON zjt_tables (tabname );

9. view the table

Select tabname from tables

Where tabname = 'zjt _ TABLES ';

10. View Columns

Select SUBSTR (COLNAME, 1, 20) as column name, TYPENAME as type, LENGTH as LENGTH

From columns

Where tabname = 'zjt _ TABLES ';

11. view the table structure

Db2 describe table user1.department

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.