Primary Key V/S Unique key

Difference between primary key and unique key are as follows: -

How to Create Primary Key

create table Course(Course_Id int primary key, Course_Name varchar(100));
or

create table Course(Course_Id int Constraint CPk primary key(Course_Id), Course_Name varchar(100));

or

create table Course(Course_Id int Constraint CPk primary key, Course_Name varchar(100));
or

create table Course(Course_Id int , Course_Name varchar(100) Constraint CPk primary key(Course_Id));

In this table you can see that in enq_type column we have entered null as we don’t have any value for this row.

How to Create Unique Key

create table t1(id int primary key, phone varchar(100) unique not null);
or
create table t2(id int primary key, phone varchar(100) constraint unk unique);
or
create table t3(id int primary key, phone varchar(100), 
email varchar(200) constraint unkphone unique(phone), constraint unkemail unique(email));

		

Email Address

For any query you can send mail at info@techaltum.com
Thanks