开发者

Editing row data not possible with binary primary key?

I'm using binary uuids for keys. Is there any way to edit table data with Mysql Workbench for this kind of schema? I end up with:

UPDATE `db`.`table` SET `foo`='bar' WHERE `uuid`=?;

Which obviously returns an error:

ERROR 0: Value not set for all parameters

I have no other way to reference the rows I want to edit.

PhpMyAdmin fails at this as well by corrupting all binary data.

edit - to clarify, the actual keys' data type is BINARY(16)

edit 2 - To c开发者_StackOverflow中文版larify even more, this question is specifically about MySQL Workbench. I understand prepared statements.

edit 3 - I'm putting a bounty on this in hopes that someone knows a workaround or solution.


You could show your table using:

SELECT *,HEX(uuid) FROM `db`.`table`;

example output:

uuid               foo      HEX(uuid)
---------------------------------------------------------------
E��|M_jE��|M_j     test     45ABFA057C4D5F6A45ABFA057C4D5F6A
.
.

then you could update it using:

UPDATE `db`.`table` SET `foo`='bar' WHERE `uuid`=UNHEX('45ABFA057C4D5F6A45ABFA057C4D5F6A');

or

UPDATE `db`.`table` SET `foo`='bar' WHERE `uuid`=CAST(0x45ABFA057C4D5F6A45ABFA057C4D5F6A AS BINARY);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜