0

1) why autoincrement is not working for varchar in phpmyadmin?
2)can we set two autoincrement in a table in phpmyadmin?

4
Contributors
3
Replies
20
Views
3 Years
Discussion Span
Last Post by diafol
4

Before asking if it is possible, perhaps you should ask why you're doing it. These are not common requests, so that should tell you that it's probably the wrong approach. Incrementing a character-based field is certainly possible, but again, why would you want to do it? If you need to create a custom 'id' - purely 'visual' for the use of screen or reports, then you can store an id as an autoincrement and create conversion functions. However, what a palaver.

An autoincrement is used to give a table row "uniqueness" and provide a "hook" in order to relate that row of data to another set of data in another table, why would you want two "uniquenesses"? BTW - there are other uses for autoincs, but those are the ones that usually come to the fore.

Some table types allow setting an autoinc field to a secondary field within a compound index (see the link from pritaeas), and this may be useful for you. BUT not all table types allow this - InnoDB, the new default type, does not AFAIK.

Edited by diafol

Votes + Comments
good explanation
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.