Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
On this page

Show all

Help Center/ GaussDB(DWS)/ More Documents/ Developer Guide (Kuala Lumpur Region)/ Syntax Compatibility Differences Among Oracle, Teradata, and MySQL

Syntax Compatibility Differences Among Oracle, Teradata, and MySQL

Updated on 2022-08-16 GMT+08:00

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.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback