You can do that using a "before insert" trigger, something like (untested) :

CREATE TRIGGER test1bi
BEFORE INSERT ON test1
  FOR EACH ROW BEGIN
    NEW.ID = COALESCE( NEW.ID, SHA1(CAST(RAND() AS CHAR)))
  END;


2007/8/7, shivendra <[EMAIL PROTECTED]>:
>
>
> Hi, I'm looking for some basic help. I am developing a MySQL database and
> want to auto increment a field, but I don't want it to just count 1,2,3,
> etc. I want the field to be a combination of letters and numbers, at least
> 8
> digits long, completely random for security porposes, but do this
> automatically, everytime a record is added. For example, ord5001, ord5002,
> ord5003, etc. Does anyone know how to do this in MySQL?
> --
> View this message in context:
> http://www.nabble.com/auto-increment-format-tf4229677.html#a12032917
> Sent from the MySQL - General mailing list archive at Nabble.com.
>
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:     http://lists.mysql.com/[EMAIL PROTECTED]
>
>


-- 
Sincerely yours,
Olexandr Melnyk
http://omelnyk.net/

Reply via email to