Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - What is the range of text fields in Mysql? And how to use it!
What is the range of text fields in Mysql? And how to use it!
The maximum length of text in mysql is 65,535 (16 to the second power–1) characters.

If you feel that the text length is not enough, you can choose:

The maximum length of 1 and MEDIUMTEXT is16,777,215.

2. The maximum length of 2.LONGTEXT is 4,294,967,295.

How to use:

Text in mysql corresponds to clob in oracle, and it is also divided into Tinytext, Text, MediumText and Long Text, all of which represent data length types.

Grammar: [UNSIGNED] mediutext

TINYTEXT: 256 bytes

Text: 65,535 bytes = > about 64kb.

Mediumtext:16,777,215 bytes = > about 16MB.

Extended data:

Fields such as text need to be used carefully, and multiple text fields will report errors. Too large a row size means too many rows.

Modification method:

1. First, query the value of the next parameter:

mysql & gtSELECT @ @ global . max _ sort _ length;

2. Then set this value: (fill in the number as needed)

mysql & gtSET GLOBAL max _ sort _ length = 2048?

Only the first max_sort_length bytes of the column are used for sorting. The default value of max_sort_length is1024; You can use the–-max _ sort _ length option to change this value when you start the mysqld server.

The difference between text and char varchar blob:

Char: Fixed length, with a maximum of 255 characters.

Varchar: variable length, up to 65,535 characters (single column and whole line are acceptable).

Text: a large object with variable length and a character set, which is sorted and checked according to the character set, regardless of case.

Blob: A large binary object with variable length, no character set and case sensitivity.