©SQL :: Manager
HomeProgram InformationTechnical detailsFree downloadDonate for a cup of coffee
myway SQL Manager for MySQL and MariaDB, Download on Uptodown
SQL functionMySQLMariaDB

The OCT SQL Function in MySQL and MariaDB - Octal value

OCTSyntax:OCT(Integer)
Return value:CHAR
Function type:Conversion function
Function Description

The OCT() function returns a string representing the octal value of "Integer".

OCT() corresponds to the function CONV(Number,10,8), floating point values are rounded down to an integer.

Character strings are interpreted as integers.

If the value of the argument is not a number, the function returns 0.

If the value of the argument is NULL, OCT() returns NULL.

SQL Examples for the OCT function

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15

SELECT oct(128);
SELECT oct(15);
SELECT oct(-128);
SELECT conv(128,10,8);
SELECT conv(15,10,8);

SELECT oct(1.2);
SELECT oct(1.6);

SELECT oct('Test');
SELECT oct('128');

SELECT oct(null);

oct(128)
varchar(64) BINARY
200
oct(15)
varchar(64) BINARY
17
oct(-128)
varchar(64) BINARY
1777777777777777777600
conv(128,10,8)
varchar(64) BINARY
200
conv(15,10,8)
varchar(64) BINARY
17
oct(1.2)
varchar(64) BINARY
1
oct(1.6)
varchar(64) BINARY
1
oct('Test')
varchar(64) BINARY
0
oct('128')
varchar(64) BINARY
200
oct(null)
varchar(64) BINARY
NULL
The examples were created with the MyWAY SQL manager: Download

How to use the OCT() function in MySQL and MariaDB databases

The OCT() function in MySQL and MariaDB is used to convert an integer value to its octal representation. The function takes a numeric value as input and returns a string of characters "0-7" representing the octal form of that value, for example to work with legacy systems or certain data formats that use octal notation use.

The octal representation returned by the OCT() function is a string and not a true octal data type. If octal arithmetic is to be performed or octal values ​​are to be stored, conversion and interpretation of octal strings may need to be performed accordingly.
NULLIFNVLNVL2OCTOCTET_LENGTHOLD_PASSWORDORD

Further MySQL und MariaDB SQL Conversion functions

BINBIN(Integer)
More about BIN Function

CASTCAST(Value AS Type)
More about CAST Function

CONVCONV(Value, from Base, to Base)
More about CONV Function

CONVERTCONVERT(Expression [, in type] [, or character set])
More about CONVERT Function

HEXHEX(Integer or 'string')
More about HEX Function

UNHEXUNHEX(String)
More about UNHEX Function

Numeric functionsString functionsRegular ExpressionsDate and Time functions
Comparison functionsEncryption & CompressionConversion functionsNULL functions
Aggregate functionsWindow functionsJSON functionsGeometric functions
Sequence functionsInformation functionsDynamic ColumnsMiscellaneous functions
More information about the OCT SQL function: mysql.com and mariadb.com
Updated: 2023-09-24ImprintContactTerms & conditionsPrivacy & CookiesUpdatesSitemapFacebookLinkedinTwitterStatistics©2020-2024 Heino Cunze-Fischer