MCQs Test!! VB Basic Test !! Essentials of VB !! Creating User Services !! function !! Anatomy !! GK March-2019 !! DATA TYPES IN JAVA !! Classes ,Constructor ,Methods,Inheritance !! Ecology-I !! Biology 2019 !! Gk april 2019 !! Biology (living world) !! Plant anatomy !! CELL STRUCTURES AND FUNCTION !! General biology !! Human physiology !! Data structure !! Ecology-II !! GK TEST !! Reproduction in plants !! Human reproduction !! The ABC of C !! Operating system set1 !! Operating system set2 !! Gk and current affairs !! Animal kingdom !! Number system !! Animal kingdom-II !! Gk TEST-III !! Number series !! Microorganisms !! Interview question in c !! Time and Work !! Percentage !! General history !! Average !! Cells !! Locomotion and Movement !! paging !! Bacteriology !! Page replacement policy !! Secondary memory and Disk scheduling !! Introduction of Nervous System and neurons !! Plant harmones !! Transport and Mineral Nutrition in Plants !! Neurotransmitters !! Modern Indian History !! Photosynthesis in Plants !! Modern Indian History-II !! Plant respiration !! Environment & Biodiversity !! Environment & Biodiversity - II !! Algae, Bryophytes, Pteridophytes !! Area !! Cricket !! Days of the Year (India and the World) !! Plant Pathology - I !! Indian Transport System !! Plant Pathology - II !! Aptitude !! Biology !! Botany !! C language !! Computer Science !! Core Java !! Gate !! GK !! Mysql !! Operating system !! Physics !! VB-Visual Basic !! Zoology

DATABASE & SQL/PLSQL

CREATING CONSTRAINTS
Previous Home Next

Constraints can be be enforced at two levels.

  1. Column level
  2. Table level

A constraints can be defined on a column at the time of creating a table. It can be created with the CREATE TABLE statement.

CREATE TABLE statement:

CREATE TABLE  table_name
column_name CONSTRAINTS  constraints_name constraints_type 
[, CONSTRAITS constraints_name constraints_type]

where, column_name is the name of the column on which the constraints is to be defined.

constraints_name is the name of the constraints to be created and must follow the rules for the identifier.

constraints_type is the type of constraints to be added.

ALTER TABLE statement:

ALTER TABLE  table_name
[WITH CHECK or WITH NOCHECK]
ADD CONSTRAINTS  constraints_name constraints_type

where, table_name is the name of the table that is to be altered for adding a constraints.

WITH CHECK and WITH NOCHECK specifies whether the existing data is to be checked or not checked for a newly added constraints or a re-enabled constraints

constraints_name specifies the name of the constraints to be created and must follow the rule for identifier.

constraints_type specifies the type of constraints

DROPPING CONSTRAINTS

A constraints dropped using the ALTER TABLE statement in the Query Analyzer.

All constraints defined in the table are dropped automatically when the table is dropped.

ALTER TABLE  table_name
DROP CONSTRAINTS  constraints_name

where, table_name is the name of the table that constraints to be dropped.

constraints_name is the name of the constraints to be dropped.

 

TYPES OF CONSTRAINTS

  1. PRIMARY KEY constraints
  2. UNIQUE constraints
  3. FOREIGN KEY constraints
  4. CHECK constraints
  5. DEFAULT constraints
Previous Home Next