REAL is defined by the SQL standard as a single-precision floating-point (approximate) numeric type. It typically maps to a 4-byte IEEE-754 float that can represent roughly 6–9 decimal digits of precision and a wide range of magnitudes. Because REAL is approximate, arithmetic and comparisons may introduce rounding error. Use REAL for scientific or statistical values where small precision loss is acceptable, not for currency or exact totals.Behavior varies by database:- PostgreSQL and Snowflake implement REAL as 4-byte float.- SQL Server maps REAL to 4-byte float.- Oracle maps BINARY_FLOAT to REAL when using ANSI syntax.- MySQL treats REAL as DOUBLE by default unless the SQL_MODE includes REAL_AS_FLOAT.- SQLite stores REAL as 8-byte float (DOUBLE) internally but preserves the REAL type affinity.REAL supports all numeric operators and aggregate functions (SUM, AVG, MIN, MAX). Conversions to and from other numeric types may truncate or round. Indexes on REAL columns work but equality comparisons can be unreliable because 0.1 cannot be represented exactly. Prefer range comparisons or rounding when filtering.Storage size, precision, and the keyword REAL itself are part of SQL-92, making the type portable across engines, but always confirm your dialect’s exact implementation.
FLOAT, DOUBLE PRECISION, NUMERIC, DECIMAL, CAST, ROUND
SQL-92 Standard
REAL typically offers about 6–9 significant decimal digits, depending on the specific value stored and the database implementation.
Values are rounded to the nearest representable binary float. Very small fractions may be stored as zero, and repeating decimals like 0.1 cannot be represented exactly.
Yes, but be cautious with equality lookups; floating-point rounding can make exact matches unreliable. Range queries generally work as expected.
Use an explicit CAST or CONVERT. Precision beyond the 6–9 digits stored in REAL cannot be recovered, so round appropriately before casting.