Differences between MySQLtext and blob Field Types

Source: Internet
Author: User
Tags mysql text
The following articles mainly introduce the differences between MySQLtext and blob field types. At the same time, this article also introduces the practical application of MySQLtext and blob field types, if you are interested in the actual operations related to the MySQLtext and blob field types, you can click and view the following articles. 1. blob is a binary large object that can accommodate

The following articles mainly introduce the differences between MySQL text and blob field types. At the same time, this article also introduces the practical application of MySQL text and blob field types, if you are interested in the actual operations related to MySQL text and blob field types, you can click and view the following articles. 1. blob is a binary large object that can accommodate

The following articles mainly introduce the differences between MySQL text and blob field types. At the same time, this article also introduces the practical application of MySQL text and blob field types, if you are interested in the actual operations related to MySQL text and blob field types, you can click and view the following articles.

1.

Blob is a large binary object that can accommodate the number of variables. blob is classified into four types: TINYBLOB, BLOB, mediumblob, and LongBlob. They hold different lengths.

There are four types of Text: TINYTEXT, TEXT, MEDIUMTEXT, and LONGTEXT.

2.

Blob is considered as a binary string, and Text is considered as a non-binary string;

Blob columns do not have character sets, and sort and compare value values based on column value bytes.

The TEXT column has a character set and sorts and compares values according to the character set's checking rules.

There is no case conversion during the storage or retrieval of MySQL TEXT or BLOB columns. When not running in strict mode, if you assign a value that exceeds the maximum length of the column type to the BLOB or TEXT column, the value is truncated to ensure proper fit. If the truncated characters are not spaces, a warning is generated.

When strict SQL mode is used, errors are generated, and the values are denied, rather than truncated, and warnings are given. In most cases, BLOB columns can be considered as VARBINARY columns that are sufficiently large. Similarly, the TEXT column can be considered as a VARCHAR column.

3.

BLOB and TEXT are different from VARBINARY and VARCHAR in the following aspects.

BLOB and TEXT Columns cannot have default values.

When you save or retrieve the values of BLOB and TEXT columns, trailing spaces are not deleted. (This is the same as the VARBINARY and VARCHAR columns ).

The index prefix length must be specified for index of BLOB and TEXT columns. For CHAR and VARCHAR, the prefix length is optional.

LONG and long varchar correspond to the MEDIUMTEXT data type. This is to ensure compatibility. If the TEXT column type uses the BINARY Attribute, BINARY proofreaders of the column character set are assigned to the column.

MySQL connector/ODBC defines BLOB as LONGVARBINARY and MySQL TEXT as LONGVARCHAR. Because BLOB and TEXT values may be very long, some constraints may be encountered when using them.

The maximum size of a BLOB or TEXT object is determined by its type, but the actual maximum value that can be passed between the client and the server is determined by the amount of available memory and the size of the Communication cache. You can change the size of the message cache by changing the value of the max_allowed_packet variable, but you must modify both the server and client programs. For example, you can use MySQL and MySQLdump to change the max_allowed_packet value of the client.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.