PostgreSQL numeric(p,s) Precision & Scale Checker
Paste the values you want to store and the column type, such as numeric(7,2), and see what PostgreSQL would save for each one: the value rounded to the declared scale, or the exact numeric field overflow error with its DETAIL line. Input parsing follows PostgreSQL's numeric rules, including scientific notation, underscores between digits, 0x/0o/0b integers, NaN and Infinity. Negative scales and scales larger than the precision (PostgreSQL 15+) are supported. The checker also suggests the smallest numeric(p,s) that stores every value without rounding. Everything runs in your browser.
Do more than postgresql numeric(p,s) precision & scale checker — meet Chat2DB
Chat2DB is an AI-powered SQL client for Windows, macOS and Linux. Write SQL in natural language, format and optimize queries automatically, and manage MySQL, PostgreSQL, Oracle and 20+ other databases in one workspace.
How to use
- Enter the column type, for example numeric(7,2), numeric(5) or plain numeric.
- Paste one value per line (quoted SQL literals like '19.99' are fine) and click Check.
- Read the stored value or error for each line, then copy the suggested type and the SQL that finds rows which would not fit.
Frequently asked questions
What does 'numeric field overflow' mean in PostgreSQL?
The value has more digits before the decimal point than the column allows. numeric(p,s) keeps s digits after the point, which leaves p - s digits before it, so numeric(5,2) accepts values whose absolute value rounds to less than 10^3, that is up to 999.99. The DETAIL line of the error states that limit.
Does PostgreSQL round or truncate extra decimal places?
It rounds to the declared scale, with ties rounded away from zero: 123.456 stored as numeric(5,2) becomes 123.46 and -0.5 stored as numeric(1,0) becomes -1. Rounding happens before the overflow check, so 999.995 fails in numeric(5,2) because it rounds up to 1000.00.
How do I fix numeric field overflow without losing data?
Widen the column with ALTER TABLE ... ALTER COLUMN ... TYPE numeric(p,s) using a larger precision, or switch to unconstrained numeric. Find the offending rows first. Chat2DB can connect to your PostgreSQL database and generate these queries with its AI assistant: download it from chat2db.ai/download or use the web version at app.chat2db.ai.
