OT: creating unique IDs for table rows
Hiya all, what's a good method for creating unique IDs for rows in a table of a database? I need to create that for an unique index which will serve as foreign key to another table. I'm currently creating a string which adds a current time (GMT) and a random number then I get a SHA digest out of it. It works well for testing purposes, but I'd like to get something more orthogonal and with more "uniqueness". BTW, the underlying RDBMS doesn't support autogenerated sequences or anything like that. Thanks, Carlos.
Carlos A. Carnero Delgado writes:
I'm currently creating a string which adds a current time (GMT) and a random number then I get a SHA digest out of it. It works well for testing purposes, but I'd like to get something more orthogonal and with more "uniqueness". BTW, the underlying RDBMS doesn't support autogenerated sequences or anything like that. If your RDBMS has a reliable transaction system, you may use your database for id generation:
m= select max(id) from id_table id= m+1 insert into id_table values(id+1) Dieter
participants (2)
-
Carlos A. Carnero Delgado -
Dieter Maurer