Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to Generate Version 1 UUIDs
Message
De
19/09/2017 04:51:25
 
 
À
19/09/2017 04:33:04
Information générale
Forum:
Visual FoxPro
Catégorie:
Client/serveur
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Network:
SAMBA Server
Database:
MySQL
Application:
Desktop
Divers
Thread ID:
01654423
Message ID:
01654427
Vues:
65
I never use MySQL, so I don't know it very well. I also admit that I had to look up UUID, which is the same as a GUID. Version 1 clearly is a variant based on the date and time, so at least for me this will be redundant since I always have a GUID field and a datetime field. My guess is that MySQL has a function to retrieve the UUID version 1 field value for the last added record, but I really can't tell for sure.

>Hi Tore,
>
>First off, thanks for your quick reply. Appreciate it.
>
>I know it's a VFP thing, but I came across this article: https://www.percona.com/blog/2014/12/19/store-uuid-optimized-way/
>
>It basically says for Version 1 type UUID values, it can be re-arranged to reflect a sequential nature if one say SELECTs from a MySQL server, because by default MySQL returns result sets arranged by primary key if ORDER is not specified.
>
>This will not necessitate adding either a datetime or autoinc column. Wouldn't this be great sir? :)
>
>
>
>
>>>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.
>>
>>If you need to see the records in the same order as they were created, you can for instance add a datetime field for this. This is what I do all the time.
>>
>>You should keep in mind that the "natural order" is a VFP thing, and is not relevant in a "real" SQL server environment. A SQL server will reuse deleted records, and it may even reorder the records if it finds it beneficial.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform