Home Sql Mysql-alter Mysql Alter Table Identity



Mysql Alter Table Identity
Posted on: January 16, 2009 at 12:00 AM
Mysql Alter Table Identity is used to change the existing structure of table and add ID column as identity key that is used to uniquely define the records in the table.

Mysql Alter Table Identity

     

Mysql Alter Table Identity is used to change the existing structure of table and add ID column as identity key that is used to uniquely define the records in the table.

Understand with Example

The Tutorial illustrate an example from 'Mysql Alter Table Identity'. To understand and elaborate an example, we create a table "userform" with required fieldnames and datatypes respectively.

Create table "userform" : 

      +----------+--------------+------+-----+---------+-------+
      | Field    | Type         | Null | Key | Default | Extra |
      +----------+--------------+------+-----+---------+-------+
      | username | varchar(100) | YES  |     |         |       |
      | fname    | varchar(100) | YES  |     |         |       |
      | email    | varchar(100) | YES  |     |         |       |
      | count    | bigint(20)   | YES  |     | 100     |       |

The Alter Table modifies the table 'userform 'and add ID as Primary Key  that uniquely identifies the records in the table.

ALTER TABLE userform ADD ID INT NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (ID);

After alter the table "userform"

      +----------+--------------+------+-----+---------+----------------+
      | Field    | Type         | Null | Key | Default | Extra          |
      +----------+--------------+------+-----+---------+----------------+
      | ID       | int(11)      | NO   | PRI |         | auto_increment |
      | username | varchar(100) | YES  |     |         |                |
      | fname    | varchar(100) | YES  |     |         |                |
      | email    | varchar(100) | YES  |     |         |                |
      | count    | bigint(20)   | YES  |     | 100     |                |
  

Related Tags for Mysql Alter Table Identity:
sqlmysqlcidetablestructsedcolumnentityidentitystructureuniquekeychangeidtabdefinerecordaddrecordstoeitalterhanguseinasmnttrstiddadaltumnuniqscolatmykishaexistingandstrrdsxissrdthstabablhatexifinlumidentidentndolo


More Tutorials from this section

Ask Questions?    Discuss: Mysql Alter Table Identity  

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.