Summary of some practical application experience of DB2 database in actual operations (1)

Source: Internet
Author: User

Today, we will focus on some practical application experience of the DB2 database in actual operations, as well as the introduction of the actual operation code involved in its actual operations, if you are interested in some practical application experience of the DB2 database in actual operations, you can learn about it through the following articles.

Create Database DB2_GCB

 
 
  1. CREATEDATABASEDB2_GCBONG:ALIASDB2_GCB  
  2. USINGCODESETGBKTERRITORYCNCOLLATEUSINGSYSTEMDFT_EXTENT_SZ32  

Connect to database

 
 
  1. connecttosample1userdb2adminusing8301206 

Create an alias

 
 
  1. createaliasdb2admin.tablesforsysstat.tables;  
  2.  
  3. CREATEALIASDB2ADMIN.VIEWSFORSYSCAT.VIEWS  
  4.  
  5. createaliasdb2admin.columnsforsyscat.columns;  
  6.  
  7. createaliasguest.columnsforsyscat.columns;  

Create a table

 
 
  1. createtablezjt_tablesas  
  2. (select*fromtables)definitiononly;  
  3. createtablezjt_viewsas  
  4. (select*fromviews)definitiononly;  

Insert record

 
 
  1. insertintozjt_tablesselect*fromtables;  
  2. insertintozjt_viewsselect*fromviews;  

Create View

 
 
  1. createviewV_zjt_tablesasselecttabschema,tabnamefromzjt_tables; 

Create a trigger

 
 
  1. CREATETRIGGERzjt_tables_del  
  2. AFTERDELETEONzjt_tables  
  3. REFERENCINGOLDASO  
  4. FOREACHROWMODEDB2SQL  
  5. Insertintozjt_tables1values(substr(o.tabschema,1,8),substr(o.tabname,1,10))  

Create a unique index

 
 
  1. CREATEUNIQUEINDEXI_ztables_tabname  
  2. ONzjt_tables(tabname);  

View table

 
 
  1. selecttabnamefromtables  
  2. wheretabname='ZJT_TABLES';  

View Columns

 
 
  1. SelectSUBSTR (COLNAME, 1, 20) as column name, TYPENAMEas type, LENGTHas Length
  2. Fromcolumns
  3. Wheretabname = 'zjt _ TABLES ';

View the table structure in a DB2 database


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.