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?

asked Nov 6, 2018 at 7:45

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.

answered Nov 6, 2018 at 8:05
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.

answered Nov 6, 2018 at 8:17

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.