Name
DB2
Synopsis
DB2 supports the SQL2003 built-in scalar functions CURRENT_DATE, CURRENT_TIME, CURRENT_TIMESTAMP, CURRENT_USER, and USER. The SQL2003 scalar functions CURRENT_ROLE, LOCAL_TIME, LOCAL_TIMESTAMP, SESSION_USER, and SYSTEM_USER are not supported.
MySQL
MySQL supports all the SQL2003 built-in scalar functions, plus Oracle’s variant SYSDATE. In addition, MySQL supports NOW( ) as a synonym of the function CURRENT_TIMESTAMP.
Oracle
Oracle supports USER and SYSDATE as a synonym of CURRENT_TIMESTAMP.
PostgreSQL
PostgreSQL supports all the SQL2003 built-in scalar functions except SESSION_USER.
SQL Server
SQL Server supports all the built-in scalar functions.
Examples
The following queries retrieve the values from built-in functions. Notice that the various platforms return dates in their native formats:
/* On MySQL */SELECT CURRENT_TIMESTAMP;
'2001-12-15 23:50:26' /* DB2 */VALUES CURRENT_TIMESTAMP
'2001-12-15 23.50.26.000000' /* On Microsoft SQL Server */SELECT CURRENT_TIMESTAMPGO
'Dec 15,2001 23:50:26' /* On Oracle */SELECT USER FROM dual;
dylan
Get SQL in a Nutshell, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.