Binary Data in MySQL

I need to store binary data such as 1110000in MySQL. When I select it, I need the return value to be the same again 1110000.

What type of data should I use? Can i use bit? Or will varbinary be better?

+3
source share
2 answers

if you are dealing with binary numbers, you can use the bit field for example:

bit(64)

- bit field with up to 64 significant bits (maximum allowed size).

to insert constant values, you can use the b'value notation as follows:

insert into bits values (b'0001001101001');

, 0 cast(). bin(), hex() oct() .

, varbinary blob . ( nil bytes tho).

, varchar char. 8 varbinary.

/ , , varbinary. # BitConverter. php /.

+9

, :


:

     select conv(column_name, from_base, to_base) from table_name
     //example:
     select conv(column1, 10, 2) from table1;

:

     insert into table_name(column1) values( B'binary_data') ;
     //example : 
     insert into table1(column1) values( B'1110000');

:

    select column1,column2 from table_name where column1 & B('binary_data');
    //example: 
    select column1, column2 from table1 where column1 & B('1110000');
+1

Source: https://habr.com/ru/post/1727835/


All Articles