Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否可以将 MySQL 中的整数列转换为二进制列并保留数据?正如您在 C 联合中看到的那样,我只想将它逐字节转换。
附录:我试过这个:
alter table foo change colname colname binary(6);
...但是这样做是将 int(5) 的字符串表示形式转换为二进制文件。我想将底层整数字节转换为二进制。
有没有办法做到这一点?
因此,例如,如果整数是 100,我希望二进制是 0x64 0x0 0x0 0x0 0x0 0x0。
谢谢。
CREATE TABLE a ( 'binary_field' BINARY(6) NOT NULL ); CREATE TABLE b ( 'int_field' INT NOT NULL ); INSERT INTO b SELECT CONVERT(binary_field, UNSIGNED) FROM a
或者您也可以使用签名