Mike Yearwood
Toronto, Ontario, Canada
Versions des environnements
>Hi Experts,
>
>For the longest time, I have been using CoCreateGuid and StringFromGUID2 to generate GUIDs. Problem with this is, whenever one simply does "select * from customer" from a MySQL Server, it does not show the customer rows in its sequential order of creation/insertion. I either need to add a column that is autoinc in nature to enforce sequential behavior.
>
>If one calls or invokes the UUID() of MySQL (or PHP), these GUID values can be spliced and reorganized to make the inserted rows sequential. This is possible due to the fact that the GUIDs they produced are of type "version 1", wherein the 4th and 5th segments are fixed. I won't be needing the added overhead of creating autoinc columns.
>
>This cannot be done however when one uses CoCreateGuid and StringFromGUID2 as the GUIDs they give are of type version 4 - wherein each segment is totally random.
>
>Aside from making a call to a MySQL server, "select uuid()" to populate my primary keys, is there another way to do this "natively"? Needless to say, this will save me a trip to the server.
>
>Thanks In Advance.
SQL Server has NEWSEQUENTIALID. You cannot get sequential guids from separate client pcs because each pc's sequence will be intermingled with the other pcs at the final data store. NewSequentialID is only used as the default value for the column. So what you'd do is update/insert your record and get the guid with the output clause. Then submit each line item with the invoice's guid and get the line items guid via the output clause. NewSequentialID guids can be clustered but you should cluster based on the most searched column. Invoice # possibly in the invoice table and invoice guid in the line items table.
Précédent
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement