When using the TO_CHAR()
function in Oracle Database, you can use the EEEE
format element to return the number in scientific notation.
Example
Here’s an example to demonstrate:
SELECT TO_CHAR(123456789, 'fm9EEEE') FROM DUAL;
Result:
1E+08
And another one:
SELECT TO_CHAR(123.456789, 'fm9EEEE') FROM DUAL;
Result:
1E+02
The TM
Format Element
You can also follow the TM
format element with a single E
if required:
SELECT TO_CHAR(123456789, 'TMe') FROM DUAL;
Result:
1.23456789E+08
Also, when using the TM
format element, if the output exceeds 64 characters, then Oracle Database automatically returns the number in scientific notation, even when there’s no E
format element:
SELECT TO_CHAR(POWER(9123456789, 9), 'TM') FROM DUAL;
Result:
4.379603308369109117980583616918225063622E+89