DOUBLE
DOUBLE is a data type in SQL, specifically used to store floating-point numbers with large precision. It allows for storage of extremely large or tiny values with decimals. DOUBLE refers to a double-precision floating-point number. Any values stored as DOUBLE are approximate, not exact values, but are accurate up to 15 digits. This data type can be used to hold numbers that are larger or more precise than those held by the FLOAT data type.
Example
Output
Explanation
In this example, a table named Employee
is created with two columns: ID
(an integer) and Salary
(a DOUBLE). A DOUBLE in MySQL is a floating-point number that allows for decimal points. The notation DOUBLE(8,2)
specifies that the Salary
numbers have a total of 8 digits, of which 2 are after the decimal point. The INSERT INTO
statement is used to add two rows of data into the Employee
table. Running SELECT * FROM Employee
then retrieves all records from the table.
Example
Output
Explanation
The provided SQL Server script declares a variable @Value
of DOUBLE
datatype and assigns it the value 10.12345. The SELECT statement is used to return this value.
Example
Output
Explanation
The DOUBLE PRECISION
data type is a floating point numeral data type that holds 15 digits of precision. It is capable of storing numbers that are substantially larger or smaller than those that can be stored in an NUMBER
data type. When retrieving data from Employee
table, it correctly displays the decimal precision in salaries.
Example
Output
To verify the data, use the following SELECT statement.
Output:
Explanation
In the example above, a new SQLite table called ‘employees’ is created with four columns: ‘id’ (an integer that serves as a primary key), ‘first_name’ (a text string), ‘last_name’ (a text string), and ‘salary’ (a double precision number).
After the table is created, data is inserted into it. The ‘salary’ field is filled with a double value, which is a number that can include fractional parts, as shown by the value 50000.75.
The SELECT statement is then used to retrieve the data from the table, confirming that the ‘salary’ value was stored accurately.