Oct Function In Sql in SQL
OCT Function in SQL
The OCT() function converts a decimal (base-10) number to its octal (base-8) representation as a string.
? Syntax:
OCT(number)number: A decimal integer to convert.
? Example:
SELECT OCT(10) AS octal_value;Result:
| octal_value |
|---|
| 12 |
Explanation: Decimal 10 = Octal 12.
Notes:
Available in MySQL.
Returns the octal representation as a string.
If input is negative, it returns the two’s complement octal value.
If you want to convert octal back to decimal, MySQL uses CONV() function or CAST() with specific conversions.
Need examples for other base conversions?