---

slug: /text-type
---

# TEXT type

The `TEXT` type is used to store all types of text data.

The text types include four types: `TINYTEXT`, `TEXT`, `MEDIUMTEXT`, and `LONGTEXT`. They correspond to the four `BLOB` types and have the same maximum length and storage requirements.

`TEXT` values are considered non-binary strings. They have a character set other than binary, and values are sorted and compared based on the collation of the character set.

When the strict SQL mode is not enabled, if the value assigned to a `TEXT` column exceeds the maximum length of the column, the excess part will be truncated and an alert will be generated. When the strict SQL mode is enabled, if the truncated part contains non-space characters, an error (not an alert) will occur, and the value will be prohibited from being inserted. Regardless of the SQL mode, an alert will always be generated when trailing spaces are truncated in the value inserted into a `TEXT` column.

## TINYTEXT

`TINYTEXT` is a `TEXT` type with a maximum length of 255 bytes.

The syntax for `TINYTEXT` is as follows:

```sql
TINYTEXT [CHARACTER SET charset_name] [COLLATE collation_name]
```

`CHARACTER SET` is used to specify the character set. If needed, you can use the `COLLATE` attribute and other attributes to specify the collation of the character set. If the binary attribute of `CHARACTER SET` is specified, the column will be created as the corresponding binary string data type, and `TEXT` will become `BLOB`.

## TEXT

The maximum length of a `TEXT` column is 65,535 bytes.

An optional length `M` can be specified for the `TEXT` type. The syntax is as follows:

```sql
TEXT[(M)] [CHARACTER SET charset_name] [COLLATE collation_name]
```

`CHARACTER SET` is used to specify the character set. If needed, you can use the `COLLATE` attribute and other attributes to specify the collation of the character set. If the binary attribute of `CHARACTER SET` is specified, the column will be created as the corresponding binary string data type, and `TEXT` will become `BLOB`.

## MEDIUMTEXT

`MEDIUMTEXT` is a `TEXT` type with a maximum length of 16,777,215 bytes.

The syntax for `MEDIUMTEXT` is as follows:

```sql
MEDIUMTEXT [CHARACTER SET charset_name] [COLLATE collation_name]
```

`CHARACTER SET` is used to specify the character set. If needed, you can use the `COLLATE` attribute and any other attributes to specify the collation of the character set. If the binary attribute of `CHARACTER SET` is specified, the column will be created as the corresponding binary string data type, and `TEXT` will become `BLOB`.

Additionally, seekdb supports the extended type `LONG`, but it is recommended to use `MEDIUMTEXT`.

## LONGTEXT

`LONGTEXT` is a `TEXT` type with a maximum length of 536870910 bytes. The effective maximum length of a `LONGTEXT` column also depends on the maximum packet size configured in the client/server protocol and the available memory.

The syntax for `LONGTEXT` is as follows:

```sql
LONGTEXT [CHARACTER SET charset_name] [COLLATE collation_name]
```

`CHARACTER SET` is used to specify the character set. If needed, you can use the `COLLATE` attribute and other attributes to specify the collation of the character set. If the binary attribute of `CHARACTER SET` is specified, the column will be created as the corresponding binary string data type, and `TEXT` will become `BLOB`.