Skip to content

REAL

CREATE TABLE Inventory (
ItemID INT AUTO_INCREMENT,
ItemName VARCHAR(100) NOT NULL,
ItemWeight REAL NOT NULL,
PRIMARY KEY (ItemID)
);
INSERT INTO Inventory (ItemName, ItemWeight)
VALUES ('Widget', 1.5),
('Gadget', 0.75);
SELECT * FROM Inventory;
+--------+----------+------------+
| ItemID | ItemName | ItemWeight |
+--------+----------+------------+
| 1 | Widget | 1.5 |
| 2 | Gadget | 0.75 |
+--------+----------+------------+

In this example, we have a SQL table named Inventory with three fields: ItemID, ItemName and ItemWeight. ItemID is an integer, ItemName is a text string, and ItemWeight is a REAL data type. The REAL data type is a floating-point number with seven digits of precision that can accept data values from -3.4E38 to 3.4E38.

In the INSERT INTO command, we insert two rows of data into the Inventorytable. The ItemWeight for each row is expressed as a REAL data value. Using the SELECT command, we display the contents of the Inventory table.