Loading

MySQL BINARY and VARBINARY Data Type

BINARY and VARBINARY Data Type:- BINARY and VARBINARY data types contain a binary string. It is similar to CHAR and VARCHAR data types. The only difference is BINARY and VARBINARY data types store byte strings rather than character strings. Length of BINARY data type can vary from 0 – 255. Depending on the length, memory consumption would range from 0 – 255 bytes.

Length of VARBINARY data type can vary from 0 – 255 before MySQL version 5.0.3 but later version length vary from 0 – 65,535. Depending on the length, memory consumption would range from 0 – 65,535 bytes.

Example:-

CREATE TABLE employee(

id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,

name BINARY(100),

email VARBINARY(255)

);

Note:- When BINARY values are stored, they are right-padded with the pad value to the specified length.

Note:- When VARBINARY values are stored, they are not padded with the pad value to the specified length.

Share with:


Leave a Reply

Connect with:





z35W7z4v9z8w