Oracle TAN Function: A Simple Guide

The TAN function in Oracle SQL is a trigonometric function that calculates the tangent of a given angle.

Like all trigonometric functions in Oracle, TAN requires the angle to be specified in radians, not degrees.

What is the TAN Function in Oracle?

The TAN(n) function takes a number n, which represents an angle in radians, and returns its tangent.

If your angle is in degrees, you must convert it to radians before passing it to the TAN function. The formula for conversion is: radians = degrees * (PI / 180).

TAN Function Syntax

The syntax for TAN is very simple:

TAN(n)

Let's break that down:

  • n (the number): The angle you want to find the tangent of, expressed in radians.

Oracle TAN Function Examples

Here are two practical examples of how to use TAN.

Example 1: Finding the Tangent of 45 Degrees

This example shows how to find the tangent of 45 degrees. We must first convert 45 degrees to radians using the formula 45 * (PI / 180). We will use 3.14159265359 as an approximation for PI.

Query:

SELECT 
  TAN(45 * 3.14159265359 / 180) AS "Tangent_of_45_Degrees"
FROM DUAL;

Result:

Tangent_of_45_Degrees
---------------------
                    1

Example 2: Finding the Tangent of 0 Degrees

This example calculates the tangent of 0 degrees (which is also 0 radians). The result is 0.

Query:

SELECT 
  TAN(0) AS "Tangent_of_0_Degrees"
FROM DUAL;

Result:

Tangent_of_0_Degrees
--------------------
                   0
Vinish Kapoor
Vinish Kapoor

Vinish Kapoor is a seasoned software development professional and a fervent enthusiast of artificial intelligence (AI). His impressive career spans over 25+ years, marked by a relentless pursuit of innovation and excellence in the field of information technology. As an Oracle ACE, Vinish has distinguished himself as a leading expert in Oracle technologies, a title awarded to individuals who have demonstrated their deep commitment, leadership, and expertise in the Oracle community.

guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments