Categories
How to SQL

How to convert the UUID to bin

Sometimes the UUIDs are in human unreadable format(Bin) and you want to find the string version of it. This is the query to do so:

select uuid_to_bin("ec52b511-d139-4b2a-a5d1-f903598055a7");  \\ 0xE552B5AAD1394B8AA4D1F903598033A3

then you can search the table using the result:

select XXX where uuid = 0xE552B5AAD1394B8AA4D1F903598033A3

Categories
Data persistance How to SQL

Steps to follow after adding new column to table

To add new column to table follow this steps:

  1. write the sql statement
  2. test it in workbench
  3. add it to sprint x->new.sql
  4. add the rollback statement that removes the column to sprint x->rollback.sql
  5. edit the corresponding XXX_init.sql, so that once init runs, it will not be confused with new column

Small hint:

How to copy data from one column to another:

update TABLE set destinationColumn=copyFromColumn;

for this to work remove the safe update from workbench settings.

Edit->Preferences->SQL editor, untick safe updates, reconnect to db