From:       To:      
Home > Documentation > Oracle to MySQL

Convert SQL Function from Oracle to MySQL

The table below illustrates how to convert the most popular Oracle built-in functions into MySQL equivalents:

Oracle MySQL
ADD_MONTHS($datetime, $n) DATEADD(month, $n, datetime)
CHR(num) CHAR(num USING ASCII)
CURRENT_DATE NOW()
CURRENT_TIMESTAMP NOW()
DECODE($exp, $when, $then, ...) CASE $exp WHEN $when THEN $then ... END
EXTRACT(YEAR FROM date) YEAR(date)
EXTRACT(MONTH FROM date) MONTH(date)
EXTRACT(DAY FROM date) DAY(date)
EXTRACT(HOUR FROM time) HOUR(time)
EXTRACT(MINUTE FROM time) MINUTE(time)
EXTRACT(SECOND FROM time) SECOND(time)
LENGTH CHAR_LENGTH
LISTAGG GROUP_CONCAT()
NVL(expr, replace) IFNULL(expr, replace)
NVL2($var,$expr1,$expr2) CASE WHEN $var IS NOT NULL THEN $expr1 ELSE $expr2 END
SYS_GUID() REPLACE(UUID(), '-', '')
TO_CHAR Click here
TO_DATE Click here
TRUNC TRUNCATE

Have questions? Contact us