Open in App
Not now

# PI() function in MySQL

• Last Updated : 05 Oct, 2020

PI() function in MySQL is used to return the Pi value. The default number of decimal places displayed is seven, but MySQL uses the full double-precision value internally.

Syntax :

`PI()`

Parameter :
This method does not accept any parameter.

Returns :
It returns the Pi value i.e. 3.141593.

Example-1 :
Returning the default value of Pi using PI Function.

```SELECT PI() AS DefaultPiValue;
```

Output :

DefaultPiValue
3.141593

Example-2 :

Returning the value of Pi up to 18 decimal places using PI Function .

```SELECT PI()+0.000000000000000000
AS PiValue;
```

Output :

PiValue
3.141592653589793000

Example-3 :
Using PI Function to calculate the area and perimeter of all circles in a column. To demonstrate, let us create a table named Circle.

```CREATE TABLE Circle(
Circle_id INT AUTO_INCREMENT,
PRIMARY KEY(Circle_id )
);
```

Now, insert some data to the Circle table.

```INSERT INTO Circle(Radius )
VALUES
(2 ),(3),(10 ),(12.5 ),(6.80),
(4.60 ),(6),(20),(25) ;
```

So, the Circle Table is as follows.

```SELECT * FROM Circle;
```
1 2.000
2 3.000
3 10.000
4 12.500
5 6.800
6 4.600
7 6.000
8 20.000
9 25.000

Now, we will calculate the area and perimeter of every circle using PI function.

```SELECT Circle_id, Radius,
2 * PI() * Radius AS Perimeter
FROM Circle;
```

Output :