Single-row and aggregate Oracle and MySQL functions
Single-row and aggregate functions are essential SQL constructs that perform operations on individual rows or groups of rows, respectively. The following sections compare Oracle and MySQL single-row and aggregate functions.
Feature compatibility | AWS SCT / AWS DMS automation level | AWS SCT action code index | Key differences |
---|---|---|---|
|
|
N/A |
MySQL doesn’t support all functions. These unsupported functions require manual creation. |
Oracle usage
Oracle provides two main categories of built-in SQL functions based on the number of rows used as input and generated as output.
-
Single-row or scalar functions return a single result for each row of the queried table or view. You can use them with a
SELECT
statement in theWHERE
clause, theSTART WITH
clause, theCONNECT BY
clause, and theHAVING
clause. The single-row functions are divided into groups according to data types such asNUMERIC
functions,CHAR
functions, andDATETIME
functions. -
Aggregative or group functions are used to summarize a group of values into a single result. Examples include
AVG
,MIN
,MAX
,SUM
,COUNT
,LISTAGG
,FIRST
, andLAST
.
See the following section for a comparison of Oracle and MySQL single-row functions.
Oracle 19 adds ability to eliminate duplicate items in LISTAGG
function results with new DISTINCT
keyword.
Oracle 19 introduces several new bitmap SQL aggregate functions such as BITMAP_BUCKET_NUMBER
, BITMAP_BIT_POSITION
and BITMAP_CONSTRUCT_AGG
. These functions help speed up COUNT DISTINCT
operations.
For more information, see Single-Row Functions
MySQL usage
MySQL provides an extensive list of single-row and aggregation functions. Some are similar to their Oracle counterparts by name and functionality, or under a different name but with similar functionality. Other functions can have identical names to their Oracle counterparts, but exhibit different functionality. In the following tables, the Equivalent column indicates functional equivalency.
Numeric functions
Oracle function and definition | MySQL function and definition | Equivalent |
---|---|---|
|
|
Yes |
|
|
Yes |
|
|
Yes |
|
|
Yes |
|
|
Yes |
|
|
Yes |
Character functions
Oracle function and definition | MySQL function and definition | Equivalent |
---|---|---|
|
|
Yes |
|
|
Yes |
|
|
Yes |
|
You can simulate Oracle |
No |
REGEXP_SUBSTR('http://www.aws.-com/products',
'http://([[:alnum:]]+\.?){3,4}/?')
|
You can simulate Oracle |
No |
|
|
Yes |
|
|
Partly |
|
|
Yes |
|
|
Yes |
|
|
Yes |
|
|
Yes |
|
|
Yes |
|
You can simulate Oracle |
No |
|
You can simulate Oracle |
No |
Date and time functions
Oracle function and definition | MySQL function and definition | Equivalent |
---|---|---|
|
|
No |
|
|
Partly |
|
|
Yes |
|
|
Yes |
|
|
Yes |
|
|
Partly |
|
|
Yes |
|
|
Yes |
|
|
Yes |
|
|
Yes |
|
You can simulate Oracle |
No |
Encoding and decoding functions
Oracle function and definition | MySQL function and definition | Equivalent |
---|---|---|
|
|
No |
|
N/A |
No |
|
|
No |
Null functions
Oracle function and definition | MySQL function and definition | Equivalent |
---|---|---|
|
|
Yes |
|
|
Yes |
|
|
Yes |
|
|
No |
|
|
No |
Environment and identifier functions
Oracle function and definition | MySQL function and definition | Equivalent |
---|---|---|
|
|
No |
|
N/A |
No |
|
|
No |
|
|
No |
Oracle conversion functions
Oracle function and definition | MySQL function and definition | Equivalent |
---|---|---|
|
|
Yes |
|
|
Yes |
|
|
No |
|
|
No |
|
N/A |
No |
Aggregate functions
Oracle function and definition | MySQL function and definition | Equivalent |
---|---|---|
|
|
Yes |
|
|
Yes |
|
|
No |
|
|
Yes |
|
|
Yes |
|
|
Yes |
Top-N Query Oracle 12c
Oracle function and definition | MySQL function and definition | Equivalent |
---|---|---|
|
|
Yes |
For more information, see String Functions and Operators