May 19, 2018 Replies: 1 If you are sure you want to use artificial primary keys in a table you might want to have a way to generate those as a GUID automatically with every INSERT. Just set (lower(hex(randomblob(16)))) as the default value. Code: CREATE TABLE [mylookuptable]( [id] GUID DEFAULT (lower(hex(randomblob(16)))), [vname] CHAR DEFAULT '>'); Keep in mind, it is pseudo random so uniqueness is not guaranteed. - SQLite Randomblob is explained here - Arguments pro/contra artificial keys mentioned here Click to expand...
If you are sure you want to use artificial primary keys in a table you might want to have a way to generate those as a GUID automatically with every INSERT. Just set (lower(hex(randomblob(16)))) as the default value. Code: CREATE TABLE [mylookuptable]( [id] GUID DEFAULT (lower(hex(randomblob(16)))), [vname] CHAR DEFAULT '>'); Keep in mind, it is pseudo random so uniqueness is not guaranteed. - SQLite Randomblob is explained here - Arguments pro/contra artificial keys mentioned here
Erel B4X founder Staff member Licensed User Longtime User May 20, 2018 #2 If you want to create a random GUID in your code: https://www.b4x.com/android/forum/threads/b4x-how-to-get-a-guidtype-simple-type.88137/#post-557601
If you want to create a random GUID in your code: https://www.b4x.com/android/forum/threads/b4x-how-to-get-a-guidtype-simple-type.88137/#post-557601