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

PRIMARY KEY Constraint
Previous Home Next

A Primary Key constraints is defined on a column whose values uniquely identify rows in a table. These columns are referred to as the primary key columns. A primary key column can not contain NULL values since it is used to uniquely identify rows in a table. the primary key ensure entity integrity.

You can define a PRIMARY KEY constraints at the time of a table creation, or you can add it later by altering the table. While defining a PRIMARY KEY constraints, you need to specify a name for the constraints. If a name is not specified, SQL server automatically assigns a name to the constraints.

CREATE TABLE table_name
(column_name data_type CONSTRAINT constraints_name PRIMARY KEY),..

 

Example:

CREATE TABLE employee (emp_name char (4) CONSTRAINT pfemp_name PRIMARY KEY)

The above command creates a table employee with emp_name as the primary key. The name of the constraints is pfemp_name.

output

Example:

Primary key also created after creating a table by following command:

ALTER TABLE  employee
ADD CONSTRAINT  Pfemp_name PRIMARY KEY  (emp_id)

output

Previous Home Next