MariaDB Tutorial MariaDB Advanced MariaDB Database Account Management MariaDB References

MariaDB OCT() Function



The MariaDB OCT() function converts a decimal number to a octal number and returns the result as a string value.

The OCT() function is equivalent to using the CONV() function with CONV(number, 10, 8) syntax.

Syntax

OCT(number)

Parameters

number Required. Specify the number to convert to a octal representation.

Return Value

Returns the octal representation of a decimal number.

Example 1:

The example below shows the usage of OCT() function.

SELECT OCT(1);
Result: '1'

SELECT OCT(8);
Result: '10'

SELECT OCT(10);
Result: '12'

SELECT OCT(64);
Result: '100'

SELECT OCT(500);
Result: '764'

SELECT OCT(1000);
Result: '1750'

Example 2:

Consider a database table called Sample with the following records:

Datax
Data 110
Data 220
Data 330
Data 440
Data 550

The statement given below can be used to get the octal representation of values of column x.

SELECT *, OCT(x) AS OCT_Value FROM Sample;

This will produce the result as shown below:

DataxOCT_Value
Data 11012
Data 22024
Data 33036
Data 44050
Data 55062

❮ MariaDB Functions