MySQL Forums
Forum List  »  Triggers

Re: How to create Auto Incremented and auto generated ID in sql
Posted by: Peter Brawley
Date: March 22, 2014 03:07PM

Trying to combine text and digits in a column is usually a design mistake. Better to maintain two columns and index as desired.

if the table is MyISAM, see http://dev.mysql.com/doc/refman/5.0/en/example-auto-increment.html.

InnoDB does not innately support auto_increment prefixes, so if the table is InnoDB, in a Trigger inside a transaction set the prefix column and calculate the value of the int colum n as (select 1+max(colname) from tablename for update).

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: How to create Auto Incremented and auto generated ID in sql
988
March 22, 2014 03:07PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.