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
- CREATEDATABASEDB2_GCBONG:ALIASDB2_GCB
- USINGCODESETGBKTERRITORYCNCOLLATEUSINGSYSTEMDFT_EXTENT_SZ32
Connect to database
- connecttosample1userdb2adminusing8301206
Create an alias
- createaliasdb2admin.tablesforsysstat.tables;
-
- CREATEALIASDB2ADMIN.VIEWSFORSYSCAT.VIEWS
-
- createaliasdb2admin.columnsforsyscat.columns;
-
- createaliasguest.columnsforsyscat.columns;
Create a table
- createtablezjt_tablesas
- (select*fromtables)definitiononly;
- createtablezjt_viewsas
- (select*fromviews)definitiononly;
Insert record
- insertintozjt_tablesselect*fromtables;
- insertintozjt_viewsselect*fromviews;
Create View
- createviewV_zjt_tablesasselecttabschema,tabnamefromzjt_tables;
Create a trigger
- CREATETRIGGERzjt_tables_del
- AFTERDELETEONzjt_tables
- REFERENCINGOLDASO
- FOREACHROWMODEDB2SQL
- Insertintozjt_tables1values(substr(o.tabschema,1,8),substr(o.tabname,1,10))
Create a unique index
- CREATEUNIQUEINDEXI_ztables_tabname
- ONzjt_tables(tabname);
View table
- selecttabnamefromtables
- wheretabname='ZJT_TABLES';
View Columns
- SelectSUBSTR (COLNAME, 1, 20) as column name, TYPENAMEas type, LENGTHas Length
- Fromcolumns
- Wheretabname = 'zjt _ TABLES ';
View the table structure in a DB2 database