跳到主要内容

PRINTF

描述

使用指定的 printf 格式字符串和参数返回格式化后的字符串。

提示

该函数自 3.0.6 版本开始支持.

语法

PRINTF(<format>, [<args>, ...])

参数

参数说明
<format>printf 格式字符串。
<args>要格式化的参数。

返回值

使用 printf 模式格式化后的字符串。

示例

select printf("hello world");
+-----------------------+
| printf("hello world") |
+-----------------------+
| hello world |
+-----------------------+
select printf('%d-%s-%.2f', 100, 'test', 3.14);
+-----------------------------------------+
| printf('%d-%s-%.2f', 100, 'test', 3.14) |
+-----------------------------------------+
| 100-test-3.14 |
+-----------------------------------------+
select printf('Int: %d, Str: %s, Float: %.2f, Hex: %x', 255, 'test', 3.14159, 255);
+-----------------------------------------------------------------------------+
| printf('Int: %d, Str: %s, Float: %.2f, Hex: %x', 255, 'test', 3.14159, 255) |
+-----------------------------------------------------------------------------+
| Int: 255, Str: test, Float: 3.14, Hex: ff |
+-----------------------------------------------------------------------------+