w3resource

MySQL OCT() function

OCT() function

MySQL OCT() returns octal value of a decimal number.

This function is useful in -

  • Octal is a base-8 numbering system that uses digits 0-7, often used in computer systems for its compact representation.
  • In Unix and Linux systems, file permissions are often represented in octal format.
  • Some database systems, particularly MySQL, use octal numbers to set various flags and modes for operations like file permissions, user privileges, and server modes.
  • Octal numbers are used in bitwise operations and manipulation.
  • In digital systems and electronics, octal numbers are used to represent groups of three binary digits (bits).
  • Octal used to be widely used in early computing systems due to its convenient representation in binary-coded decimal (BCD) form.

Syntax:

OCT(num)

Argument:

Name Description
num A decimal number whose octal representation is to be retrieved.

Syntax Diagram:

MySQL OCT() Function - Syntax Diagram

MySQL Version: 8.0


Example: OCT() function

Code:

SELECT OCT('55');

Explanation:

The above MySQL statement returns an octal representation of the decimal number 55.

Output:

mysql> SELECT OCT('55');
+-----------+
| OCT('55') |
+-----------+
| 67        | 
+-----------+
1 row in set (0.03 sec)

All Mathematical Functions

Previous: MOD()
Next: PI()



Follow us on Facebook and Twitter for latest update.