Updated on 2024-05-14 GMT+08:00

String Functions

Table 1 String functions

No.

MySQL

GaussDB

Difference

1

ASCII()

Supported

-

2

BIT_LENGTH()

Supported

-

3

CHAR_LENGTH()

Supported, with differences.

In GaussDB, if the character set is SQL_ASCII, CHAR_LENGTH() returns the number of bytes instead of characters.

4

CHARACTER_LENGTH()

Supported, with differences.

In GaussDB, if the character set is SQL_ASCII, CHARACTER_LENGTH() returns the number of bytes instead of characters.

5

CONCAT()

Supported

If the return value type in MySQL is binary string (such as BINARY, VARBINARY, or BLOB), the return value type in GaussDB is LONGBLOB. If the return value type in MySQL is non-binary string (such as CHAR, VARCHAR, or TEXT), the return value type in GaussDB is TEXT.

6

CONCAT_WS()

Supported

If the return value type in MySQL is binary string (such as BINARY, VARBINARY, or BLOB), the return value type in GaussDB is LONGBLOB. If the return value type in MySQL is non-binary string (such as CHAR, VARCHAR, or TEXT), the return value type in GaussDB is TEXT.

7

HEX()

Supported

-

8

LENGTH()

Supported

-

9

LPAD()

Supported, with differences.

  • The default maximum padding length in MySQL is 1398101, and that in GaussDB is 1048576. The maximum padding length depends on the character set. For example, if the character set is GBK, the default maximum padding length in GaussDB is 2097152.
  • If the database character set is SQL_ASCII, unexpected results may occur.
  • If the return value type in MySQL is binary string (such as BINARY, VARBINARY, or BLOB), the return value type in GaussDB is LONGBLOB. If the return value type in MySQL is non-binary string (such as CHAR, VARCHAR, or TEXT), the return value type in GaussDB is TEXT.

10

REPEAT()

Supported

If the return value type in MySQL is binary string (such as BINARY, VARBINARY, or BLOB), the return value type in GaussDB is LONGBLOB. If the return value type in MySQL is non-binary string (such as CHAR, VARCHAR, or TEXT), the return value type in GaussDB is TEXT.

11

REPLACE()

Supported

If the return value type in MySQL is binary string (such as BINARY, VARBINARY, or BLOB), the return value type in GaussDB is LONGBLOB. If the return value type in MySQL is non-binary string (such as CHAR, VARCHAR, or TEXT), the return value type in GaussDB is TEXT.

12

RPAD()

Supported, with differences.

  • The default maximum padding length in MySQL is 1398101, and that in GaussDB is 1048576. The maximum padding length depends on the character set. For example, if the character set is GBK, the default maximum padding length in GaussDB is 2097152.
  • If the database character set is SQL_ASCII, unexpected results may occur.
  • If the return value type in MySQL is binary string (such as BINARY, VARBINARY, or BLOB), the return value type in GaussDB is LONGBLOB. If the return value type in MySQL is non-binary string (such as CHAR, VARCHAR, or TEXT), the return value type in GaussDB is TEXT.

13

SPACE()

Supported

-

14

STRCMP()

Supported, with differences.

If the database character set is SQL_ASCII, unexpected results may occur.

15

FIND_IN_SET()

Supported, with differences.

When characters are specified to be encoded in SQL_ASCII for the database, the server parses byte values 0 to 127 according to the ASCII standard, and byte values 128 to 255 cannot be parsed. If the input and output of the function contain any non-ASCII characters, the database cannot help you convert or verify them.

If the return value type in MySQL is binary string (such as BINARY, VARBINARY, or BLOB), the return value type in GaussDB is LONGBLOB. If the return value type in MySQL is non-binary string (such as CHAR, VARCHAR, or TEXT), the return value type in GaussDB is TEXT.

16

LCASE()

17

LEFT()

18

LOWER()

19

LTRIM()

20

REVERSE()

21

RIGHT()

22

RTRIM()

23

SUBSTR()

24

SUBSTRING()

25

SUBSTRING_INDEX()

26

TRIM()

27

UCASE()

28

UPPER()

29

UNHEX()

Supported

The return value type in MySQL is BINARY, VARBINARY, BLOB, MEDIUMBLOB, or LONGBLOB, while the return value type in GaussDB is fixed to LONGBLOB.