SQL query to add primary key

In this article, we will figure out how to compose a SQL Query to add primary key to a section?

Primary key: This key is utilized to characterize the uniqueness of segment as there consistently ought to be a one of a kind line of information for this segment.

This is imperative to have one primary key. A primary key is a property of a segment, which characterizes that the segment will have one of a kind values.

The Simple yet incredible example of this idea is Roll Number of an understudy. The Roll Number consistently contains extraordinary value unfailingly.

For what reason is primary key so significant? All things considered, there are various responses to it, yet what, one of the less talked about contention is that primary key assistance to interface diverse table together without any problem.

This gives us so much force that we ought not stress over the space, as at whatever point we have to utilize the record all we will do is utilize the primary key.

Table (worker) having three fields and four information in it,

    Id		Name		Address

    100		Aman		Mumbai
    200		Arun		Pune
    300		Karan		Delhi
    400		Aman		Mumbai

As should be obvious the above table have three sections, they didn’t characterize as a primary key however assume we have to include a primary key segment id the we should simply, utilize adjust table and alter the segment to include a primary key with the name of the segment as the parameter in it.

Query 1:

ALTER TABLE employee 


SQL query to add primary key

Leave a Comment

error: Alert: Content is protected!!