At 11:29 PM -0500 12/15/08, Rob Gould wrote:
update mytable set hash_field = md5(AutoIdField + unix_timestamp())
I _think_ I understand that - - - - but what does the "AutoldField"
variable mean?
He probably intends AutoIdField to be a stand-in for whatever your
current auto increment column is called. You probably want to create
a unique index -
http://dev.mysql.com/doc/refman/5.0/en/create-index.html
- on hash_value as well for (1) performance and (2) to ensure against
duplicate values (which are, admittedly, pretty unlikely).
Another alternative is to use the uuid() function -
http://dev.mysql.com/doc/refman/5.0/en/miscellaneous-functions.html#function_uuid
- instead of the md5() above, eg
update mytable set unique_field=uuid();
- steve
On Monday, December 15, 2008, at 09:37PM, "Bastien Koert"
<phpster@xxxxxxxxx> wrote:
On Mon, Dec 15, 2008 at 9:29 PM, Rob Gould <gouldimg@xxxxxxx> wrote:
I have a mySQL database with 700,000 records in it, which are presently
keyed with an "auto-increment" field.
What I'd like to do is create another field with a field where each and
every record number has a unique keyvalue. Example: "su5e23vlskd" for
records 1, and "34fdfdsglkdj4" for record 2. All that matters is that it's
unique, and isn't a number that can be guessed or an
"autoincrement" number,
where a hacker can just figure out the keyvalue by incrementing
numbers. It
doesn't matter to me if each keyvalue field is just numbers, or a
number/letter combination - - - all that matters is that each
keyvalue field
is unique. Is there an automatic way that mySQL could do that, or would I
need to write a php script to somehow go through each record and
create this
unique value?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
update mytable set hash_field = md5(AutoIdField + unix_timestamp())
--
Bastien
>Cat, the other other white meat
--
+--------------- my people are the people of the dessert, ---------------+
| Steve Edberg http://pgfsun.ucdavis.edu/ |
| UC Davis Genome Center sbedberg@xxxxxxxxxxx |
| Bioinformatics programming/database/sysadmin (530)754-9127 |
+---------------- said t e lawrence, picking up his fork ----------------+
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php