If you are going to implement real security, it shouldn't matter if someone nows the "unique id" of a record. You should be checking if they have the right to see that record.

But regardless, there is an easy way to set random ids as your "unique" identifier. Setup 2 fields, one being the random number of string that you generate, the other being an auto_increment field. You primary key will be the combination of these field (random +autoincrement). The auto_increment field will almost always be 1 until there is a conflict with the random ids, in which case it will increment. The downside is that all your queries (joins too) will need to reference 2 fields instead of 1.

On Aug 7, 2007, at 8:05 AM, shivendra wrote:


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/mysql? [EMAIL PROTECTED]



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to