Scientific notation shows up in SQL results when a numeric column is stored or cast as a floating-point type and the value is large or small enough for the engine to switch formats. To avoid it, store whole numbers in integer types or exact decimals (DECIMAL/NUMERIC), cast before or during output, and format the displayed string explicitly. The method depends on your engine and on whether the problem is the stored data type or only the client's display. Fixing the type is the durable solution; formatting fixes the symptom.
The core issue is representational, not aesthetic. Floating-point types trade exactness for range: an 8-byte double can hold enormous values but only about 15–17 significant decimal digits exactly, so engines routinely print them in exponent form. Exact types and string formatting sidestep that behavior entirely.
Why SQL Engines Switch to Scientific Notation
SQL engines don't have a single "number" type. Each family behaves differently, and the notation appears for predictable reasons.
Floating-point storage. Types like FLOAT, REAL, and DOUBLE PRECISION (or FLOAT(n) in MySQL, where n is a precision hint rather than a display width) are binary floating-point. When a value's magnitude is far from 1, the engine's default text conversion may choose exponent notation. For example, a FLOAT column returning 1.23457e+08 is showing roughly 123,457,000, but the exact integer may already be lost because the stored binary value isn't exactly that integer.
Implicit casts and arithmetic. Mixing an integer with a float in an expression promotes the result to float. SELECT 100000000 * 1.0 can produce a float-typed result that some clients render in exponent form even though both inputs looked ordinary.
Client rendering, not server storage. Many tools (command-line clients, BI tools, ORMs) format floats themselves. The server may return a decimal string and the client still displays 1E+8. This distinction matters: if the data is stored correctly, no CAST in your query will change what the client draws.
Aggregates. AVG(), SUM() over floats, and statistical functions return float types in most engines, so an average of large integers can surface as 4.5e+06.
JSON and export paths. Serializers sometimes emit exponent notation for doubles. A correct database value can still appear wrong in a CSV or JSON export produced by an application layer.
The practical upshot: diagnose whether the notation comes from the column type, an expression, or the client before choosing a fix.
First Diagnose: Type or Display?
Before changing anything, confirm where the exponent format originates.
1: Inspect the column type. Use the engine's catalog: information_schema.columns (portable across MySQL, PostgreSQL, SQL Server, and others), PRAGMA table_info(table_name) in SQLite, or DESCRIBE table_name in MySQL. Look for float, real, double, or binary_float/binary_double. 2: Run a typed probe. SELECT CAST(col AS DECIMAL(38,0)) FROM t LIMIT 5; If the exponent disappears, the server-side result formatting is the issue. If the digits look wrong (for example, 123456789012345678 becomes 123456789012345680), the stored float has already lost precision and no formatting will recover it. 3: Check the client separately. Compare the same query in two clients, or pipe output through a plain text tool. If one client shows 1.2e+09 and another shows 1200000000, the data is fine and the fix belongs in that client's settings or in an explicit formatted column.
A useful sanity check: compare col with CAST(col AS DECIMAL(38,10)) and see whether the decimal expansion has trailing nonzero digits beyond what the value should have. Extra digits signal binary float artifacts.
The Durable Fix: Choose Exact Types at Design Time
The only way to guarantee no scientific notation and no hidden rounding is to stop storing numeric identifiers and money as floats.
Integers for counts and IDs. INTEGER, BIGINT, and their engine variants hold whole numbers exactly. A BIGINT covers ±9,223,372,036,854,775,807, enough for most identifiers and counters. DECIMAL/NUMERIC for money and fixed-scale quantities. DECIMAL(19,4) stores exact values with four decimal places. PostgreSQL, SQL Server, MySQL, Oracle, and SQLite all support this type family with exact arithmetic. In SQLite, NUMERIC affinity stores values as integers or reals depending on the literal, so read the affinity rules carefully if you rely on exactness there. Store identifiers as text if they aren't arithmetic. Account numbers, tracking codes, and phone-like values should be VARCHAR/TEXT so no engine ever reinterprets them. Avoid FLOAT for anything you'll display verbatim. Keep it for measurements where relative precision is what matters and the client is configured to format it.
If you control the schema, this is where the problem ends. Migrating an existing FLOAT column to DECIMAL or BIGINT is usually straightforward but should be done with a verified cast: check for values that don't round-trip, since floats may hold artifacts like 0.30000000000000004.
Casting in Queries: Portable and Engine-Specific Approaches
When you can't change the schema, cast at query time. The standard form is CAST(expr AS type); many engines also accept the shorthand expr::type.
Decimals instead of floats. CAST(amount AS DECIMAL(19,4)) forces an exact, fixed-scale rendering. For whole numbers stored as floats, CAST(col AS DECIMAL(38,0)) strips the fractional part (and rounds, in most engines), producing a plain integer string.
Integer casts for counts. CAST(col AS BIGINT) or CAST(col AS SIGNED) (MySQL) makes the result an integer type that clients render without an exponent.
Rounding before casting. CAST(ROUND(col, 2) AS DECIMAL(19,2)) avoids a long artifact tail. Note that ROUND on a float still operates on the binary value, so results near .5 boundaries can surprise you; exact types avoid that.
Engine variations. PostgreSQL accepts NUMERIC and ::numeric. SQL Server uses DECIMAL/NUMERIC and CONVERT(type, expr, style). Oracle uses NUMBER and TO_CHAR with format models. MySQL has DECIMAL, SIGNED, and UNSIGNED cast targets. SQLite is dynamically typed and has no true DECIMAL storage class; casting there changes affinity, not storage, so string formatting is often the practical fix.
Important caveat. A cast changes the result type and therefore the server-side text conversion, but it cannot restore digits a float already lost. Verify with the probe described above.
Formatting for Display: Strings You Control
When the client insists on exponent form, or when you need a guaranteed layout, produce the string yourself.
PostgreSQL: TO_CHAR(col, 'FM999999999999999999990') produces a plain integer string with no exponent and no leading spaces. For decimals, TO_CHAR(col, 'FM999999999999990.00'). The FM prefix removes padding. Oracle: TO_CHAR(col, 'FM9999999999999999990') works similarly; Oracle's TO_CHAR with numeric format models is the long-standing way to suppress exponent output. SQL Server: FORMAT(col, 'N0') returns a grouped numeric string (locale-dependent separators); CONVERT(VARCHAR(30), CAST(col AS DECIMAL(38,0))) is more predictable. Older versions lack FORMAT, so the CONVERT route is safer. MySQL: FORMAT(col, 0) returns a string with grouping commas; CAST(col AS CHAR) on an integer-typed value avoids exponents. TRIM(TRAILING '.' FROM ...) cleans up artifacts when needed. SQLite: printf('%.0f', col) or CAST(col AS TEXT) on an integer-affinity value.
A formatted string is the right answer when the downstream consumer is a report, a CSV, or a UI that must not show exponents. It's the wrong answer when the value must remain numeric for further math.
Setting and Session Options That Change Rendering
Some engines let you change output behavior without rewriting queries.
PostgreSQL: SET extra_float_digits = 3; changes how many digits are emitted for floats. It affects precision, not the choice of exponent notation, and PostgreSQL's default float output already uses the shortest round-trip representation. Scientific notation still appears for very large floats, so this is a partial lever at best. Oracle: SET NUMWIDTH in SQL*Plus widens the display column so values aren't truncated into exponent form, though very large numbers can still print with an E. SET NUMFORMAT applies a format model globally, which is a genuine fix in that client. MySQL command line: the --column-type-info flag helps inspect types; display width options like --vertical change layout, not notation. SQL Server Management Studio: grid output respects the column's type; there's no session toggle for exponent format. Cast or format instead. Client-level settings: DBVisualizer, DBeaver, and many BI tools have per-type formatting options. DBeaver, for example, lets you define how numeric types display. These are tool-specific and version-dependent, so check your tool's documentation rather than assuming a setting exists.
Treat session options as a convenience for interactive work, not a guarantee for applications. An application reading a float will still face float semantics.
Worked Examples Across Common Engines
The following snippets are illustrative and assume a table t with a float column v holding values like 123456789 and 0.000045.
PostgreSQL. Casting to NUMERIC yields exact decimals; TO_CHAR gives you the string directly.
SQL Server. DECIMAL(38,0) is the widest exact fixed-point type, so use it when you don't know the magnitude in advance. If the values have fractional parts, choose a scale that fits them.
MySQL. MySQL's DECIMAL allows up to 65 total digits, which covers very large integers.
Oracle. Oracle's NUMBER handles large integers exactly up to its precision limits.
SQLite. SQLite is the least type-strict engine, so string formatting is the most reliable way to pin the display. Check the values with typeof(v) to see what storage class you actually have.
A concrete arithmetic check: if you store 123456789 as a 4-byte REAL (single precision), the nearest representable value is not exactly that integer. Casting to DECIMAL(38,0) afterward will show the rounded value the engine actually held, which is why choosing an exact type before the first insert matters.
Convert or Format? Matching the Fix to the Job
Use the type of the target, not the look of the value today.
| Need | Best approach | Why |
|---|---|---|
| Exact storage going forward | DECIMAL/NUMERIC or BIGINT in the schema | Removes float semantics entirely |
| One-off report export | TO_CHAR/FORMAT/CONVERT to string | Guarantees layout for any consumer |
| Ad-hoc query in an interactive client | Cast to exact type, or client display setting | Reversible and quick; no schema change |
| Application display | Format in the application layer (e.g., locale-aware number formatting) | Keeps numeric type for math, controls presentation |
| Existing float column with precision loss | Migrate the column and re-derive values from a trustworthy source | Formatting cannot recover lost digits |
The distinction between conversion and formatting is the most common source of confusion. A CAST to DECIMAL converts the value's type and changes server-side rendering; it's usually what you want for further math. A TO_CHAR-style conversion produces text that's stable for display but no longer usable in arithmetic without casting back.
Edge Cases and Common Traps
Very large integers beyond float range. A BIGINT can hold values a DOUBLE can only approximate past roughly 9e15. If you cast a float holding 123456789012345678 to DECIMAL, you'll get the float's approximation, not the original. Only exact storage preserves such values.
Locale separators. FORMAT() in SQL Server and FORMAT() in MySQL both produce grouping separators that depend on locale or session settings; that output is a string and should not be parsed back into a number without stripping separators.
Negative zero and tiny values. Floats can render -0 or small values as -1e-07; casting to a DECIMAL with too few fractional digits rounds them to zero. Decide whether that's acceptable before deploying.
DECIMAL overflow. Choosing DECIMAL(38,0) is safe for most cases, but values with many fractional digits need scale. A cast that overflows raises an error in strict engines and may truncate in looser ones.
JSON serialization. Even after fixing SQL output, an ORM may serialize a double type into JSON with exponent notation. That's an application-layer fix, not a SQL one.
Views and computed columns. If a view exposes a float expression, clients see the float. Wrap the expression in a cast inside the view to control what downstream consumers receive.
The stop condition for self-service fixes is precision loss: if the stored float artifacts are already baked into reporting, reconcile against a source of truth before migrating, and involve whoever owns the data pipeline rather than silently changing types.
Key Takeaways
Scientific notation is a floating-point display behavior; the durable fix is storing exact values in INTEGER/BIGINT or DECIMAL/NUMERIC. Diagnose first: check information_schema.columns, then compare a DECIMAL cast against the raw value to see whether the issue is display or genuine precision loss. Cast at query time for one-off fixes; format with TO_CHAR, FORMAT, or CONVERT when you need a guaranteed string layout. Session and client display settings can help interactive work but don't change how an application consumes the data. Verify arithmetic by hand on a sample value: if the decimal expansion shows stray nonzero digits, the float has already lost information and only a schema migration from a reliable source will fix it. Engine syntax differs; the same DECIMAL concept maps to NUMERIC, NUMBER, or affinity rules, so test the cast on your engine and version before rolling it out.