Help Center/ GaussDB(DWS)/ More Documents/ Developer Guide (Paris Region)/ Syntax Compatibility Differences Among Oracle, Teradata, and MySQL
Updated on 2022-07-29 GMT+08:00

Syntax Compatibility Differences Among Oracle, Teradata, and MySQL

GaussDB(DWS) is compatible with Oracle, Teradata and MySQL syntax, of which the syntax behavior is different.

Table 1 Compatibility differences

Compatibility Item

Oracle

Teradata

MySQL

Empty string

An empty string is treated as NULL.

An empty string is distinguished from NULL.

An empty string is distinguished from NULL.

Conversion of an empty string to a number

NULL

0

0

Automatic truncation of overlong characters

Not supported

Supported (set GUC parameter td_compatible_truncation to ON)

Not supported

NULL concatenation

Returns a non-NULL object after combining a non-NULL object with NULL.

For example, 'abc'||NULL returns 'abc'.

The strict_text_concat_td option is added to the GUC parameter behavior_compat_options to be compatible with the Teradata behavior. After the NULL type is concatenated, NULL is returned.

For example, 'abc'||NULL returns NULL.

Is compatible with MySQL behavior. After the NULL type is concatenated, NULL is returned.

For example, 'abc'||NULL returns NULL.

Concatenation of the char(n) type

Removes spaces and placeholders on the right when the char(n) type is concatenated.

For example, cast('a' as char(3))||'b' returns 'ab'.

After the bpchar_text_without_rtrim option is added to the GUC parameter behavior_compat_options, when the char(n) type is concatenated, spaces are reserved and supplemented to the specified length n.

Currently, ignoring spaces at the end of a string for comparison is not supported. If the concatenated string contains spaces at the end, the comparison is space-sensitive.

For example, cast('a' as char(3))||'b' returns 'a b'.

Removes spaces and placeholders on the right.

concat(str1,str2)

Returns the concatenation of all non-NULL strings.

Returns the concatenation of all non-NULL strings.

If an input parameter is NULL, NULL is returned.

left and right processing of negative values

Returns all characters except the first and last |n| characters.

Returns all characters except the first and last |n| characters.

Returns an empty string.

lpad(string text, length int [, fill text])

rpad(string text, length int [, fill text])

Fills up the string to the specified length by appending the fill characters (a space by default). If the string is already longer than length then it is truncated (on the right). If fill is an empty string or length is a negative number, null is returned.

If fill is an empty string and the string length is less than the specified length, the original string is returned. If length is a negative number, an empty string is returned.

If fill is an empty string and the string length is less than the specified length, an empty string is returned. If length is a negative number, null is returned.

log(x)

Returns the logarithm with 10 as the base.

Returns the logarithm with 10 as the base.

Returns the natural logarithm.

mod(x, 0)

Returns x if the divisor is 0.

Returns x if the divisor is 0.

Reports an error if the divisor is 0.

Data type DATE

Converts the DATE data type to the TIMESTAMP data type which stores year, month, day, hour, minute, and second values.

Stores year and month values.

Stores year and month values.

to_char(date)

The maximum value of the input parameter can only be the maximum value of the timestamp type. The maximum value of the date type is not supported. The return value is of the timestamp type.

The maximum value of the input parameter can only be the maximum value of the timestamp type. The maximum value of the date type is not supported. The return value is of the date type in YYYY/MM/DD format. (The GUC parameter convert_empty_str_to_null_td is enabled.)

The maximum value of the input parameter can only be the maximum value of the timestamp type. The maximum value of the date type is not supported. The return value is of the date type.

to_date, to_timestamp, and to_number processing of empty strings

Returns NULL.

Returns NULL. (The convert_empty_str_to_null_td parameter is enabled.)

to_date and to_timestamp returns NULL. If the parameter passed to to_number is an empty string, 0 is returned.

Return value types of last_day and next_day

Returns values of the timestamp type.

Returns values of the timestamp type.

Returns values of the date type.

Return value type of add_months

Returns values of the timestamp type.

Returns values of the timestamp type.

If the input parameter is of the date type, the return value is of the date type.

If the input parameter is of the timestamp type, the return value is of the timestamp type.

If the input parameter is of the timestamptz type, the return value is of the timestamptz type.

CURRENT_TIME

CURRENT_TIME(p)

Obtains the time of the current transaction. The return value type is timetz.

Obtains the time of the current transaction. The return value type is timetz.

Obtains the execution time of the current statement. The return value type is time.

CURRENT_TIMESTAMP

CURRENT_TIMESTAMP(p)

Obtains the execution time of the current statement. The return value type is timestamptz.

Obtains the execution time of the current statement. The return value type is timestamptz.

Obtains the execution time of the current statement. The return value type is timestamp.

LOCALTIME

LOCALTIME(p)

Obtains the time of the current transaction. The return value type is time.

Obtains the time of the current transaction. The return value type is time.

Obtains the execution time of the current statement. The return value type is time.

LOCALTIMESTAMP

LOCALTIMESTAMP(p)

Obtains the time of the current transaction. The return value type is timestamp.

Obtains the time of the current transaction. The return value type is timestamp.

Obtains the execution time of the current statement. The return value type is timestamp.

SYSDATE

SYSDATE(p)

Obtains the execution time of the current statement. The return value type is timestamp(0).

Obtains the execution time of the current statement. The return value type is timestamp(0).

Obtains the current system time. The return value type is timestamp(0).

NOW()

Obtains the time of the current transaction. The return value type is timestamptz.

Obtains the time of the current transaction. The return value type is timestamptz.

Obtains the statement execution time. The return value type is timestamptz.

Operator ^

Performs exponentiation.

Performs exponentiation.

Performs the exclusive OR operation.

Different input parameter types of CASE, COALESCE, IF, and IFNULL expressions

Reports error.

Is compatible with behavior of Teradata and supports type conversion between digits and strings. For example, if input parameters for COALESCE are of INT and VARCHAR types, the parameters are resolved as VARCHAR type.

Is compatible with behavior of MySQL and supports type conversion between strings and other types. For example, if input parameters for COALESCE are of DATE, INT, and VARCHAR types, the parameters are resolved as VARCHAR type.