0

I've read that In MySQL, BLOBs are often used to store image files, file path pointers, video & audio files, and any other big data objects.

But can BLOBs be used for simple Strings that are converted into byte[] (like names, address, etc.) or would VARBINARY suffice?

Or does it not really impact the database size and query performance?

2 Answers 2

2

Main differences between VARBINARY and BLOB are:

  • VARBINARY must have length specification, BLOB must not (but may);
  • Index by BLOB must have prefix length specification, VARBINARY must not (but may);
  • VARBINARY may have default value, BLOB cannot.

can BLOBs be used for simple Strings that are converted into byte[] (like names, address, etc.) or would VARBINARY suffice?

Both variants are possible. The influence on the query performance depends of the query.

2

does it not really impact the database size and query performance.

As per MySQL documentation The BLOB and TEXT Types In most respects, you can regard a BLOB column as a VARBINARY column that can be as large as you like. Similarly, you can regard a TEXT column as a VARCHAR column. BLOB and TEXT differ from VARBINARY and VARCHAR in the following ways:

Each BLOB or TEXT value is represented internally by a separately allocated object. This is in contrast to all other data types, for which storage is allocated once per column when the table is opened.

In some cases, it may be desirable to store binary data such as media files in BLOB or TEXT columns. You may find MySQL's string handling functions useful for working with such data. See Section 12.5, “String Functions”. For security and other reasons, it is usually preferable to do so using application code rather than giving application users the FILE privilege.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.