FLOAT8

FLOAT8 is a data type used to store single-precision, floating-point numbers. This type can hold values up to 15 decimal digits long, with a range that supports positive, negative, and zero values. FLOAT8 provides higher precision and larger range than its counterpart, FLOAT4, making it appropriate for computations requiring advanced precision. The storage size required for FLOAT8 is 8 bytes.

Example

CREATE TABLE FloatTest (
floatColumn FLOAT8
);
INSERT INTO FloatTest (floatColumn) VALUES (352.424);
SELECT * FROM FloatTest;

Output

+------------+
| floatColumn|
+------------+
| 352.424|
+------------+

Explanation

In this example, a table named FloatTest is created with one column named floatColumn of type FLOAT8. A row is then inserted with the value 352.424 into floatColumn. The selection query returns this value.

Example

CREATE TABLE floats (
my_float FLOAT8
);
INSERT INTO floats(my_float)
VALUES (12.734);
SELECT *
FROM floats;

Output

my_float
----------
12.734
(1 row)

Explanation

In the example, a table named floats is created with a single column my_float of the FLOAT8 type. Then, one row is inserted into the floats table with a FLOAT8 value of 12.734. The SELECT statement is executed to return all the data from the floats table, which in this case is only the single row containing 12.734.

Example

DECLARE
num_test FLOAT8;
BEGIN
num_test := 135.74;
dbms_output.Put_line ('Value of num_test is '|| num_test);
END;

Output

Value of num_test is 135.74

Explanation

In the example, a variable num_test of type FLOAT8 is declared and assigned the value 135.74. The dbms_output.Put_line command is used to output the value of num_test. It displays the statement “Value of num_test is 135.74”.

For in-depth explanations and examples SQL keywords where you write your SQL, install our extension.