민서네집

[MySQL] Binary Data 넣기 본문

Database/MySQL

[MySQL] Binary Data 넣기

브라이언7 2013. 12. 12. 15:07

Insert hex values into MySql

stackoverflow.com/questions/3126210/insert-hex-values-into-mysql

You can use UNHEX() function to convert a hexstring with hex pairs to binary and HEX() to do the other way round.

I.e.

INSERT INTO tbl (col) VALUES (UNHEX('4D2AFF'))

and

SELECT HEX(col) FROM tbl


CREATE TABLE IF NOT EXISTS `TEST_TBL` (
  `totalCount` VARBINARY(500) ,
  `useCount` VARBINARY(500)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='테스트 테이블';

INSERT INTO TEST_TBL VALUES(UNHEX('4D2AFF00OBODOA'),UNHEX('4D2AFF00OBODOA'));

COMMIT;

Comments