Home Sql Mysql-alter SQL Primary Key



SQL Primary Key
Posted on: January 13, 2009 at 12:00 AM
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;

 

Related Tags for SQL Primary Key:
sqlcdatabaseidetabledatanullincludeseduniquekeyvalueidtabifierecordrecordsvaluestobaseeachldsheprimarynotuseuliminnoasmntclesasedouniqsatkincishalleaandarrdsvassrirdthshoavabablaluidentidentprndonlyononl


More Tutorials from this section

Ask Questions?    Discuss: SQL Primary Key  

Post your Comment


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

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.