Hello,
I'm trying to add a column to a table of mine to include a unique identifier using the mysql function UUID(). I tried this query to alter the table (that at the moment has about 8K records)
ALTER TABLE `users` ADD `uuid` VARCHAR( 50 ) NOT NULL DEFAULT 'UUID()' AFTER `id` ;
This query add the column, but sets the field with the default value of "UUID()" in all records, instead of the unique identifier for each of them.
I also tried this
ALTER TABLE `users` ADD `uuid` VARCHAR( 50 ) NOT NULL DEFAULT UUID() AFTER `id` ;
But I got a mysql error:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UUID() AFTER
id
' at line 1
Is there a way I can set UUID() function as an default value for my table, so that all existing records get an UUID and new records too?
Thanks,