How to query and create a table using DB2

Source: Internet
Author: User

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.

 
 
  1. db2 =>create table t1 ( id integer,name varchar(12),address varchar(50))  
  2.  
  3. db2 =>insert into t1 values(1,'wjz','sdfsfds'),(2,'lw','v4')  
  4.  
  5. db2 => select * from t1  
  6.  
  7. ID          NAME         ADDRESS  
  8. ----------- ------------ --------------------------------------------------  
  9.           1 wjz          sdfsfds  
  10.           2 lw           v4  

Two records are selected.

 
 
  1. Db2 => create table t3 as (select id, name from t1) data initially deferred refresh deferred
  2.  
  3. Db2 => refresh table t3
  4. The DB20000I SQL command is successfully completed.
  5. Db2 => select * from t3
  6.  
  7. ID NAME
  8. -----------------------
  9. 1 wjz
  10. 2 lw

Two records are selected.

 
 
  1. Db2 => insert into t1 values (3, 'wxb ', 'csk ')
  2. The DB20000I SQL command is successfully completed.
  3. Db2 => refresh table t3
  4. The DB20000I SQL command is successfully completed.
  5. Db2 => select * from t3
  6.  
  7. ID NAME
  8. -----------------------
  9. 1 wjz
  10. 2 lw
  11. 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

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.