Online Training Spring Hibernate Training in Delhi R Programming Training Course Big Data and Hadoop Training Java Training

SQL Primary Key

The Primary Key in SQL is used to uniquely identifies each records in a database table.

Ads

SQL Primary Key

     

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;

 

Advertisements

Share on Google+Share on Google+

SQL Primary Key

Posted on: January 13, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Advertisements

Ads
 

Discuss: SQL Primary Key  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0

Ads

 

Ads