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


The DEFAULT Constraint
Previous Home Next

A default constraint can be used to assign a constant value to a column, and the user need not insert values for such a column . Only one DEFAULT constraint values can be created for a column , but the column cannot be an IDENTITY column. The system-supplied values like USER, CURRENT_USER, and user defined values can be assigned as defaults.

CREATE TABLE  table_name
(column_name data_type  DEFAULT [constant_expression])

where, constraint_name specifies the name of the constraint to be created.

constant_expression specifies an expression that contains only constant values and can contain NULL.


CREATE TABLE  employee
(cCity char (14)  DEFAULT  'New Delhi', emp_id  varchar(15))

The above command use to create a DEFAULT constraint on the cCity attribute. If a city is not specified, then the cCity attribute would contain 'New Delhi' by default.



If table already created then using ALTER command we specified the DEFAULT constraint

ALTER TABLE  employee
ADD CONSTRAINT  defcCity  DEFAULT  'New Delhi'  FOR  cCity


Previous Home Next