Вопрос

What is the default value for a binary column? Should it be specified when the column is "NOT NULL"? And how should it be specified?

I ask the above because after increasing the size of my password column from binary(32) NOT NULL to binary(60) NOT NULL, all the logins failed. The hex of all the passwords are now zero-padded like this to fill up the entire column:

+-------------------------------------------------------------------------------+
| hex(password)                                                                 |
+-------------------------------------------------------------------------------+
| B41DF3CA2BFB639FA62DA56DF475EBC1E5C054E6CF00000000000000000000000000000000000 |
+-------------------------------------------------------------------------------+

What should be the proper way of handling the expansion of a binary password column?

Это было полезно?

Решение

In MySQL BINARY is fixed length, which is why the value is padded. You probably want VARBINARY(60) which behaves like VARCHAR in that it does not pad on the right.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top