For our next project, we're considering to switch to UUIDs as primary keys for database tables. The project will run on HSQLDB, Derby, DB2 and Oracle, maybe MySQL. Data will not have to be migrated between databases (often), so the "uniqueness" over many DBs is not so much an issue for us.
The main advantage for us currently is that each client can generate UUIDs and put them into the persisted objects which saves a round-trip during object generation. Also, having the client's MAC address and the time stamp in the UUID might help when hunting an error (since we could see where an object came from, i.e. in which log file to look).
Unfortunately, none of these databases supports a native UUID type. Oracle uses RAW(16), in DB2 and Derby, I can use CHAR(16) FOR BIT DATA, HSQLDB has BINARY(16).
Our current concerns are:
- Handling of the binary data when manually selecting rows in an SQL tool
- No more
select *
(without writing our own SQL tool) - Tables will be twice the size
Can someone confirm our concerns? Has anyone ever had to implement UUIDs across a multitude of different databases? What were your experiences?