How can I add "AUTO_INCREMENT" for a field?
| User, date | Message |
|---|---|
|
Written by johnnylee194
6 years ago Category: General 2 posts since Thu, 19 Apr 07 |
I was trying to add the "AUTO_INCREMENT" property to a filed. But I found that if I used "create field...", the check-box of the AutoIncrement is un-available. If I create a filed, then try to add the property by "edit field...", then I will be prompt that the default value is invalid. How can I solve this problem? |
|
Written by johnnylee194
6 years ago 2 posts since Thu, 19 Apr 07 |
johnnylee194 wrote: *snip* For the second issue, if i remove the default value, it will be OK. like this: ALTER TABLE `recipes` CHANGE `id` `id` INT(32) UNSIGNED AUTO_INCREMENT |
|
Written by siMKin
6 years ago 104 posts since Sun, 01 Apr 07 |
johnnylee194 wrote: An auto_increment field needs to be defined as a key. So, first you have to create the field, then define it as your primary key and then you can set it to auto_increment wrote: If I create a filed, then try to add the property by "edit field...", then I will be prompt that the default value is invalid. wrote: For the second issue, if i remove the default value, it will be OK. You must have (accidentally) defined is as your primary key as well, otherwise that query wouldn't work. |
|
Written by trudge
6 years ago 4 posts since Sun, 17 Jun 07 |
You must have (accidentally) defined is as your primary key as well, otherwise that query wouldn't work.[/quote] Can someone explain how to make a field a primary key please? Ive searched and found no definitive answers, yet you refer to creating one. Many thanks. |
|
Written by ansgar
6 years ago 3951 posts since Fri, 07 Apr 06 |
Just click on the "Manage Indexes" button with the flash on it (left to the field list) |
|
Written by trudge
6 years ago 4 posts since Sun, 17 Jun 07 |
anse wrote: Just click on the "Manage Indexes" button with the flash on it (left to the field list) In any case I did manage to get my field defined as a primary key. I had to drop the table first, then in my SQL import script, add the proper command to make my field a primary key and auto_increment. But it does seem strange that Heidi doesn't have a feature to alter a field dynamically. I'm coming from a phpMySQL GUI so this is a little different. But I definitely like it a lot. |
|
Written by ansgar
6 years ago 3951 posts since Fri, 07 Apr 06 |
trudge wrote: :) I saw that but thought it was for an index, not a primary key. Am I missing something here? They are different. A primary key can be seen as an index, so the index editor has these tasks gathered. |
|
Written by trudge
6 years ago 4 posts since Sun, 17 Jun 07 |
anse wrote: trudge wrote: :) I saw that but thought it was for an index, not a primary key. Am I missing something here? They are different. Ah. Thank you. I see that 'Primary Key' is now an option in the select list for managing indexes (indices?). btw, any idea why my sig is not being attached. I have it set ON in my profile. |
|
Written by ansgar
6 years ago 3951 posts since Fri, 07 Apr 06 |
trudge wrote: Ah. Thank you. I see that 'Primary Key' is now an option in the select list for managing indexes (indices?). Hehe. I'm nearly sure that it's "indexes", not "indices". I looked it up some time. trudge wrote: btw, any idea why my sig is not being attached. I have it set ON in my profile. I disabled displaying signatures due to spamming problems. Sorry for any inconveniance. |
|
Written by ansgar
6 years ago 3951 posts since Fri, 07 Apr 06 |
Revision 629 displays both tabs "field editor" and "index editor" at the same time. http://svn.sourceforge.net/heidisql/?rev=629&view=rev |
|
Please login to leave a reply, or register at first. |