HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

What does the vertical pipe slash operator do?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
thewhatoperatorslashpipedoesvertical

Problem

I'm wondering what pipe slash |/ does in,

SET equal_area_radius = |/area/pi();


The statement works and it definitely changes the value:

SELECT |/125.555/pi(); --  returns: 6.32181918120139
SELECT 125.555/pi();   --  returns: 39.9653977598058


What does the pipe-slash operator |/ do?

Solution

The |/ operator calculates the square root

postgres>  select |/16,  sqrt(16);
 ?column? | sqrt
----------+------
        4 |    4
(1 row)


So |/125.555/pi() is equivalent to sqrt(125.555/pi())

Code Snippets

postgres>  select |/16,  sqrt(16);
 ?column? | sqrt
----------+------
        4 |    4
(1 row)

Context

StackExchange Database Administrators Q#226690, answer score: 5

Revisions (0)

No revisions yet.