Documentation Home
MySQL 8.3 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 40.8Mb
PDF (A4) - 40.9Mb
Man Pages (TGZ) - 294.0Kb
Man Pages (Zip) - 409.0Kb
Info (Gzip) - 4.0Mb
Info (Zip) - 4.0Mb
Excerpts from this Manual

30.4.5.3 format_bytes() 函数

Note

从 MySQL 8.0.16 开始,format_bytes() 已弃用,并将在未来 MySQL 版本中删除。使用它的应用程序应该迁移到使用内置的 FORMAT_BYTES() 函数。见 第 14.21 节,“性能模式函数”

将字节计数转换为人类可读格式,并返回一个字符串,包括值和单位指示符。根据值的大小,单位部分是 字节KiB(kibibytes)、MiB(mebibytes)、GiB(gibibytes)、TiB(tebibytes)或 PiB(pebibytes)。

参数
  • bytes TEXT:要格式化的字节计数。

返回值

一个 TEXT 值。

示例
mysql> SELECT sys.format_bytes(512), sys.format_bytes(18446644073709551615);
+-----------------------+----------------------------------------+
| sys.format_bytes(512) | sys.format_bytes(18446644073709551615) |
+-----------------------+----------------------------------------+
| 512 bytes             | 16383.91 PiB                           |
+-----------------------+----------------------------------------+