We all know that the number π is a mathematical constant that is the ratio of a circle's circumference to its diameter.
Most databases provide a built in function that can be used to display a representative value of PI. I thought it would be fun to check a few databases to see which one serves up the most accurate juiciest slice of PI by default!
MySQL
MySQL is accurate to 6 digits **:
Code: Select all
MySQL> select pi();
+----------+
| pi() |
+----------+
| 3.141593 |
+----------+
1 row in set (0.00 sec)
MS SQL Server is accurate to 14 digits
Oracle
Yikes, Oracle does not have a PI function, but we can simulate it using one of the following two techniques where the first one is more accurate to 8 digits:[/b]
Code: Select all
SQL> select asin(1)*2 from dual;
ASIN(1)*2
----------
3.14159265
Code: Select all
SQL> select 22/7 from dual;
22/7
----------
3.14285714
Vertica is accurate to 50 digits:
Code: Select all
dbadmin=> select pi();
pi
------------------------------------------------------
3.14159265358979323846264338327950288419716939937510
(1 row)
** To be fair, MySQL does store the full double-precision value internally:
Code: Select all
dbadmin=> SELECT pi() + 0.00000000000000000000000000000000000000000000000000 bigger_pi;
bigger_pi
------------------------------------------------------
3.14159265358979323846264338327950288419716939937510
(1 row)