Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQLite, how to disable scientific notation

Tags:

sqlite

I have a column of type real, when I do a query on that column (using SQLite3 command line interface) the data is shown in scientific notation, not much amusing particularly because the numbers after the exponent are sometimes truncated and not shown (weird!). I've been trying to find a way to change 7.62939453125e-06 to its more friendly representation 0.00000762939453125 (I'd be happy with 7 decimal digits), to no avail. I'm using version 3.8.2, so printf is not an available choice. I even tried round(number*1000000)/1000000, same result.

like image 296
Merca Avatar asked Aug 31 '25 06:08

Merca


1 Answers

The best way I have found to prevent scientific notation is to use the printf function:

sqlite> SELECT abs(1.0/1000000);
1.0e-06
sqlite> SELECT printf('%f', abs(1.0/1000000));
0.000001

Here's a link to the official docs: https://www.sqlite.org/lang_corefunc.html#printf

like image 148
likebike Avatar answered Sep 04 '25 05:09

likebike