Text Type
The text data type is a UTF8-encoded text with Unicode support, which stores a sequence of characters (text).
STRING is an alias for the TEXT data type. You can create a table using STRING. However, it will be stored and processed equivalently to TEXT.
Let’s create an employee table with a text data type in each column:
Insert the text value between the single quotes ' '.
The created table is shown below:
The substr() function extracts a specific number of characters from a text.
Let’s analyze the above syntax:
- text is the specified text.
- start_position is used as the starting position, specifying the part from which the substring will be returned. It is written as an int value.
- length is used to determine the number of characters to be extracted. It can be one or more characters.
The first position in the text is 1.
Insert a value into the text column.
The updated table is shown below:
The length() function returns the number of characters in a text.
The number of characters might be different from the byte length.
The length function will take a text as a parameter.
Insert a value into the text column.
The updated table is shown below.
The length() function will also count spaces.
