When creating a table why we use PRIMARY KEY. what is the reault | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

When creating a table why we use PRIMARY KEY. what is the reault

PRIMARY KEY

5th May 2019, 9:45 AM
Ajay Sharma
3 Answers
+ 13
Hello !!! While creating any database table using SQL, primary key is important. Primary Key cannot contain null values and must contain unique values. Suppose you create a table Student_Info and the columns are RollNo, Name, Age and Marks. Now this database table is used to store records of all students, so the field RollNo for all students is the main attribute from which we identify the students in the table uniquely, as two or more students can have same name, same age and same marks. But no two or more students can have same Roll Numbers. So RollNo field should be unique(different) and should be Not Null(Not Empty). and the RollNo is made the Primary Key. So primary key is basically used to identify your table uniquely. Hope This Helps !!!
5th May 2019, 10:31 AM
Nova
Nova - avatar
+ 7
Primary key uniquely identifies each row in your table . https://www.sololearn.com/discuss/184541/?ref=app
5th May 2019, 10:33 AM
Rstar
Rstar - avatar
+ 7
https://www.sololearn.com/learn/SQL/1849/?ref=app
5th May 2019, 10:34 AM
Rstar
Rstar - avatar