-
Add auto increame field in MYSQL table
Auto Increment field in MYSQL table
If one want to add auto increment field to a MYSQL table, use mysql commands to achieve this.
First go to the mysql prompt on your server.
[root@server ~]# mysql
mysql> use database;
Replace database with your database-name.
mysql> create table tableautoincrement (
-> auto-increment-field MEDIUMINT NOT NULL AUTO_INCREMENT,
-> PRIMARY KEY (id)
-> );
Replace tableautoincrement with your actual table-name for which you want to set auto-increment.
Also replace auto-increment-field with your field name.
-
I even tried to set the auto increment count first and then alter the table to add auto increment property so as to avoid duplicate id generation but still no luck,
here are my commands::
ALTER TABLE instances AUTO_INCREMENT = ;
ALTER TABLE instances MODIFY COLUMN instance_id INT(10) NOT NULL AUTO_INCREMENT;
Last edited by evantanski; 01-17-2012 at 07:04 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks