Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mysql byte array storage

I have a byte array created in Java. It represents content of some file. I don't know exactly the maximum size of this array. It can be different sizes. I want to store it in mysql. What type should I use in mysql?

like image 317
user1379574 Avatar asked Jul 03 '12 10:07

user1379574


People also ask

What is stored in a byte array?

A byte is 8 bits (binary data). A byte array is an array of bytes (tautology FTW!). You could use a byte array to store a collection of binary data, for example, the contents of a file. The downside to this is that the entire file contents must be loaded into memory.

Can array be stored in MySQL?

Although an array is one of the most common data types in the world of programming, MySQL actually doesn't support saving an array type directly. You can't create a table column of array type in MySQL. The easiest way store array type data in MySQL is to use the JSON data type.

How big is a byte array?

The bytearray class is a mutable sequence of integers in the range of 0 to 256.

What is the size of Longtext in MySQL?

LONGTEXT can store the maximum characters among all four, up to 4,294,967,295 characters i,e 4,294,967,295 bytes or 4GB. This is more than enough storage for any long-form text strings.


2 Answers

Use BLOB, medium blob , varbinary

Mysql Choosing the Right Type for a Column

like image 66
Nikson Kanti Paul Avatar answered Oct 21 '22 19:10

Nikson Kanti Paul


Use varbinary to store byte arrays of arbitrary length in MySQL.

like image 34
Sergey Kalinichenko Avatar answered Oct 21 '22 19:10

Sergey Kalinichenko