

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How will you add a constraint on above DB2 table TAB1 for ages between 3 to 16 years?
Constraints are used to restrict the data inserted at a particular column. Constraints can be used in such a way that a value can only be inserted if it satisfies the condition given in constraints. We can give the below parameter during CREATE TABLE command to add a constraint.
CREATE TABLE DBSET1.TAB1 (STUDENT_ID CHAR(10) NOT NULL, ENROLLMENT_ID CHAR(20) NOT NULL, NAME VARCHAR(50), AGE SMALLINT CONSTRAINT NUMBER CHECK (AGE >=3 AND AGE <=16) PRIMARY KEY (STUDENT_ID));
The CONSTRAINT NUMBER CHECK reserved words can be followed by the permissible range that a column can have. It can be accompanied by logical operators like AND, NOT, OR to adjust the value range.
- Related Questions & Answers
- How to add a new column Address in the above DB2 table TAB1?
- How to add a unique index on the above table TAB1 for column Enrollment ID (ascending)?
- How to add a row compression to a DB2 table TAB1?
- How to delete a DB2 table TAB1?
- How to create an ALIAS TAB2 for DB2 table TAB1?
- How to find out all the indexes for a DB2 table TAB1?
- How to do a full & incremental MERGECOPY for a DB2 table TAB1?
- How to create a view on table TAB1 for column Name, age, enrollmentId & age > 10 years. >
- How to find the primary key of a DB2 table TAB1?
- How to get the list of all COBOL-DB2 programs using a DB2 table TAB1?
- How will you create a new TRIGGER on the ORDERS DB2 table? Give the syntax of TRIGGER
- How to image copy the entire DB2 table TAB1 into a dataset?
- How to find all the foreign keys of a DB2 table TAB1?
- How will you extract multiple rows from a DB2 table in a single FETCH call?
- What happens if I will add a UNIQUE constraint on the same column for multiple times?
Advertisements