Documentation Home
MySQL 8.0 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 43.3Mb
PDF (A4) - 43.4Mb
Man Pages (TGZ) - 297.2Kb
Man Pages (Zip) - 402.4Kb
Info (Gzip) - 4.3Mb
Info (Zip) - 4.3Mb
Excerpts from this Manual

30.4.5.3 The format_bytes() Function

Note

As of MySQL 8.0.16,format_bytes() is deprecated and subject to removal in a future MySQL version. Applications that use it should be migrated to use the built-inFORMAT_BYTES() function instead. SeeSection 14.21, “Performance Schema Functions”

Given a byte count, converts it to human-readable format and returns a string consisting of a value and a units indicator. Depending on the size of the value, the units part isbytes,KiB (kibibytes),MiB (mebibytes),GiB (gibibytes),TiB (tebibytes), orPiB (pebibytes).

Parameters
  • bytes TEXT: The byte count to format.

Return Value

ATEXT value.

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