Jump to content

[SOLVED] alter table


AV1611

Recommended Posts

I can't work out the syntax of how to do this:

 

I need to alter an existing table.  I need to add an int column, and have it auto-increment it.

 

alter table tablename add column ID  int(5);

 

how do i make it autoincrement?

 

//EDIT

Is this right?

 

alter table tablename add column ID MEDIUMINT NOT NULL AUTO_INCREMENT;

Link to comment
https://forums.phpfreaks.com/topic/74801-solved-alter-table/
Share on other sites

That didn't work neither did this:

 

alter table rdqout add column id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id);

 

You can't seem to set a field to AUTO_INCREMENT unless it's a KEY, and you can't set the KEY unless it's AUTO_INCREMENT...

 

Is this a limitation of MySQL?

 

I am dynamically creating the table, and need to add the ID field so i can do further manipulations.

Link to comment
https://forums.phpfreaks.com/topic/74801-solved-alter-table/#findComment-378245
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.