You may not know how to use DB2 to query and create tables. The following describes how to use DB2 to query and create tables. We hope that you can have a better understanding of DB2 queries.
- db2 =>create table t1 ( id integer,name varchar(12),address varchar(50))
-
- db2 =>insert into t1 values(1,'wjz','sdfsfds'),(2,'lw','v4')
-
- db2 => select * from t1
-
- ID NAME ADDRESS
- ----------- ------------ --------------------------------------------------
- 1 wjz sdfsfds
- 2 lw v4
Two records are selected.
- Db2 => create table t3 as (select id, name from t1) data initially deferred refresh deferred
-
- Db2 => refresh table t3
- The DB20000I SQL command is successfully completed.
- Db2 => select * from t3
-
- ID NAME
- -----------------------
- 1 wjz
- 2 lw
Two records are selected.
- Db2 => insert into t1 values (3, 'wxb ', 'csk ')
- The DB20000I SQL command is successfully completed.
- Db2 => refresh table t3
- The DB20000I SQL command is successfully completed.
- Db2 => select * from t3
-
- ID NAME
- -----------------------
- 1 wjz
- 2 lw
- 3 wxb
Three records are selected.
The preceding method is to use DB2 to query and create a table.
Introduction to DB2 recursive query
Implementation of DB2 Paging
DB2 cursor and usage
How to manage DB2 tablespaces
DB2 database Permissions