I need to transfer data from one system A to system B. System A stores user ids are UUID and system B stores them as integers.
I am using MySQL select statement to retrieve and save data from System A and then transferring it across to System B. Is there an easy way to convert UUID into an integer in MySQL select statement?
As discussed in comments, you cannot simply turn a UUID into an integer and expect it to be unique. A UUID is 128-bits, versus
INT(10)which is probably 32-bits. This means you have to ignore 96 bits, which equates to a very large number of potential collisions (around 78 octillion different UUIDs for every unique 32-bit value).Not all is lost, because in 32 bits you can represent up to around 4 billion users and that’s probably enough. All you really need to do is map your existing UUIDs to an integer, and that’s actually quite straight-forward.
To achieve this, you can make a translation table that stores both UUID (as the primary key) and a unique integer (perhaps an auto-increment field). You can use this to map from System A to System B (and vice versa). You can put this table into either of the two databases, or you can keep it separate. Personally, I would put it into System B, because that is where the
userIdinteger values actually make sense.