The Primary Key in SQL is used to uniquely identifies each records in a database table.The Primary Key in SQL is used to uniquely identifies each records in a database table.
The Primary Key in SQL is used to uniquely identifies each records in a database table. The Primary Key of the Table does not include NULL values. In SQL Each Table should have primary key and have only one primary key.
Understand with Example
The Tutorial illustrate an example from 'SQL Primary Key'. To understand and grasp this example, we create a table 'users' with the primary key 'user_id'. The field name 'user_id' does not include a null value.
Create Table users:
|create table users(user_id int not null primary key,last_name varchar(25) not null,first_name varchar(25),address varchar (50),city varchar(50));
Insert Values into table 'users' :
The insert into add the records or rows to the table 'users'.
To View the Details of table 'users' :
To view the table detail 'users' we run the select keywords that returns you the set of records from table 'users' with primary key 'user_id'.
|select * from users;|