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