SQL statement for creating tables in DB2 with Constraints

Source: Internet
Author: User

The DB2 table creation statements described below contain constraints. the DB2 table creation statements are for your reference and hope to help you learn about the DB2 table creation statements.

 
 
  1. CREATE TABLE EMPLOYEE
  2.  
  3. (Empno intgrate not null primary key,
  4.  
  5. Job varchar (10) CONSTRAINT CHECH_JOB
  6.  
  7. CHECK (job in ('engineer ', 'sales', 'manager ')),
  8.  
  9. ...,
  10.  
  11. CONSTRAINT CHECK_AGE_SALRY CHECK (NOT (AGE <30 and salary> 6000 ))
  12.  
  13. )
  14.  
  15. 2. CREATE TABLE EMPDATA
  16.  
  17. (Empno intgrate not null,
  18.  
  19. Sex char (1) not null constraint sexok check (sex in ('M', 'F '))
  20.  
  21. Not enforced // DB2 do NOT force this column check when inserting or updating
  22.  
  23. Enable query optimization, // DB2 uses it when running the SELECT statement on the table
  24.  
  25. Salary intgrate not null,
  26.  
  27. Constraint salaryok check (salary between 0 AND 100000)
  28.  
  29. NOT ENFORCED
  30.  
  31. ENABLE QUERY OPTIMIZATION
  32.  
  33. )

Three types of DB2 database backup solutions

DB2 logfilsiz parameter settings

DB2 command line connection

How to reset the silent State of the DB2 tablespace

Create a DB2 tablespace in windows

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.