Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Sql Mysql-alter SQL Primary Key

Related Tutorials


 
 

Share on Google+Share on Google+

SQL Primary Key

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

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

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: January 13, 2009

Related Tutorials

Discuss: SQL Primary Key  

Post your Comment


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