SQL 方言参考/函数和表达式/其他表达式
外观
< SQL 方言参考
SQL 版本 | 功能 | 标准 SQL:2011 |
DB2 | Firebird | Ingres | Linter | MSSQL | MySQL Vers. 5.x |
MonetDB | Oracle Vers. 11.x |
PostgreSQL | SQLite | Virtuoso |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
? | 将值 val 转换为数据类型 type | CAST(val AS type) | ? | CAST(val AS type) | ? | CAST(val AS type) CASTexpression as type TO_CHAR TO_NUMBER TO_DATE |
CAST(val AS type) CONVERT(type, val, style) |
CONVERT(val, type) CAST(val AS type) |
CAST(val AS type) CONVERT(val, type) |
CAST(val AS type) | CAST(val AS type) val::type |
CAST(val AS type) | ? |
? | 用fallback值替换val中的NULL,如果val是非NULL,则返回val | COALESCE(val, fallback) | ? | ? | ? | NVL(val, fallback) | COALESCE(val, fallback) ISNULL(val, fallback) |
IFNULL(val, fallback) | COALESCE(val, fallback) | COALESCE(val, fallback) NVL(val, fallback) |
COALESCE(val, fallback) | IFNULL(val, fallback) COALESCE(val, fallback) |
? |
? | 从一系列值(val1, val2, ...)中返回第一个非NULL值 | COALESCE(val1, val2, ...) | COALESCE(val1, val2) | COALESCE(val1, val2, ...) | ? | COALESCE(val1, val2, ...) | COALESCE(val1, val2, ...) | COALESCE(val1, val2, ...) | COALESCE(val1, val2, ...) | COALESCE(val1, val2, ...) | COALESCE(val1, val2, ...) | COALESCE(val1, val2, ...) | ? |
? | 将特定值转换为NULL:如果a = b则返回NULL,否则保留a | NULLIF(a, b) | ? | NULLIF(a, b) | ? | NULLIF(a, b) | NULLIF(a, b) | NULLIF(a, b) | NULLIF(a, b) | NULLIF(a, b) | NULLIF(a, b) | NULLIF(a, b) | ? |