First thing you'll want to do is to make sure you've got a UNIQUE index on this new column, of course.
Next, you'll need to define how these 16 random characters should be generated. For example, what types of characters? How about line break characters? Or backspace characters? Null characters?
steamPunk;11000406 wrote:Does MySQL have a function that would enable me to populate all the rows with a unique id just using a single UPDATE query ?
like : UPDATE clients
SET identifier=(?????)
You might be able to do execute a query like:
UPDATE clients
SET identifier = RIGHT( [i]example_func[/i](), 16 )
WHERE LENGTH( identifier ) != 16
repeatedly until all rows have an identifier, but I don't know if that would work (what with the UNIQUE constraint and all - depending upon how likely example_func/i is of generating duplicate values). Note that example_func/i is, of course, just a placeholder - you'll need to use whatever function(s) you desire to generate the sequence of characters. MySQL's UUID() comes to mind.
steamPunk;11000406 wrote:would it be possible to set this up so that the string is automatically generated and inserted by MySQL when a new row is created ?
See the section entitled 17.3 Using Triggers in the MySQL manual for one way of doing this at the DB rather than in your application(s).