Primary Keys and Auto Increment Fields in MySQL

Answer

Primary Key:
A primary key is used to uniquely identify a row in a table. A table can have only one primary key. The values in a single column to store primary key are unique. More one column can be used as a primary key. When used, the combination of column values must be unique.

Auto Increment attribute:
The Auto Increment attribute is used to generate unique values for new rows. Value once used by a row, can not be used for another row.

The following example illustrates the use of both primary key and auto increment attribute.

CREATE TABLE Products (
id NOT NULL AUTO_INCREMENT,
product_name CHAR(30) NOT NULL,
PRIMARY KEY (id)
);

All sql dba Questions

Ask your interview questions on sql-dba

Write Your comment or Questions if you want the answers on sql-dba from sql-dba Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 





Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---