Oracle兼容-函数-CAST()函数


1. 语法

  1. CAST(expr AS VARCHAR(N))

2. 定义和用法

在原生 CAST() 函数的基础上,增加了在语法层面对VARCHAR(N)类型的支持。

3. 示例

  1. greatsql> SELECT CAST('greatsql' AS VARCHAR(10)), CAST('greatsql' AS VARCHAR(5));
  2. +---------------------------------+--------------------------------+
  3. | CAST('greatsql' AS VARCHAR(10)) | CAST('greatsql' AS VARCHAR(5)) |
  4. +---------------------------------+--------------------------------+
  5. | greatsql | great |
  6. +---------------------------------+--------------------------------+
  7. 1 row in set, 1 warning (0.00 sec)
  8. greatsql> SHOW WARNINGS;
  9. +---------+------+-----------------------------------------------+
  10. | Level | Code | Message |
  11. +---------+------+-----------------------------------------------+
  12. | Warning | 1292 | Truncated incorrect CHAR(5) value: 'greatsql' |
  13. +---------+------+-----------------------------------------------+

问题反馈

联系我们

扫码关注微信公众号

greatsql-wx