SQL REAL Data Type

The REAL data type is an approximate number with floating point numeric data.

REAL value is approximate which means not all range of values can be represented exactly.

REAL is equivalent to FLOAT(24).

Example

#

A table with a 2 REAL columns.

CREATE TABLE DemoTable  
( 
  Id INT IDENTITY, 
  PatientName VARCHAR(100),
  Celsius REAL,
  Fahrenheit REAL
);
GO  

INSERT INTO DemoTable VALUES ('Harold Smith', 36.2, 97.16);  
INSERT INTO DemoTable VALUES ('Robert Johnson', 35.8, 96.44);  
INSERT INTO DemoTable VALUES ('Janice Lopez', 37.32, 99.176);
INSERT INTO DemoTable VALUES ('Kelly Wilson', 35.89, 96.602); 
INSERT INTO DemoTable VALUES ('Grace Taylor', NULL, NULL); 
GO  

SELECT * FROM DemoTable;
GO

DROP TABLE DemoTable;
GO
Result:  5 records
Id PatientName Celsius Fahrenheit
1 Harold Smith 36.2 97.16
2 Robert Johnson 35.8 96.44
3 Janice Lopez 37.32 99.176
4 Kelly Wilson 35.89 96.602
5 Grace Taylor NULL NULL

More Examples

REAL with OTHER APPROXIMATE NUMERIC TYPES

Problem: Confirm that FLOAT(24) and REAL values are identical.
CREATE TABLE DemoTable  
( 
  MyFloat FLOAT(24),
  MyReal REAL
);
GO  

INSERT INTO DemoTable VALUES (1899.982, 1899.982);  
GO  

SELECT * FROM DemoTable;
GO

DROP TABLE DemoTable;
GO
Result:  1 record
MyFloat MyReal
1899.982 1899.982

You may also like



Guides


vsn 3.1