NUMERIC (arbitrary-precision decimal)

Last updated: 2026-11-04

NUMERIC (arbitrary-precision decimal)

NUMERIC is PostgreSQL's exact decimal type, and DECIMAL is a fully equivalent spelling. It stores decimal digits in a variable-length array and can represent up to 131072 digits before the decimal point and 16383 after it. Because its arithmetic is exact, 0.1 + 0.2 = 0.3 holds strictly. With NUMERIC(p, s), p is the total number of significant digits and s the number of decimal places; excess decimal places are rounded rather than rejected.

Kindtype
Example LanguageSQL

📝 Syntax

NUMERIC  |  DECIMAL  |  DEC  ——  arbitrary precision when unqualified
NUMERIC(precision, scale)  ——  precision is total significant digits, scale is decimal places
NUMERIC(p)  ——  equivalent to NUMERIC(p, 0)

Returns:Stores an exact decimal. Without a declared precision it grows as needed; with one, excess decimal places are rounded to the given scale, and an integer part wider than the declared precision raises "numeric field overflow".

▶ Example

Runs real PostgreSQL 18 right in your browser (PGlite WASM, nothing to install). Press ▶ Run and the result appears in the panel below.

Output:

 id |  price  |         ratio          | col_type | exact_equal
----+---------+------------------------+----------+-------------
  1 | 1234.57 | 0.33333333333333333333 | numeric  | t

📌 Key Points

More case studies coming soon.

📚 Related Reference

❓ FAQ

QWhat do p and s mean in NUMERIC(p, s)?
Ap caps the total number of significant digits, integer and fractional parts combined, and s is the number of decimal places. numeric(10,2) holds up to 8 integer digits plus 2 decimals, i.e. -99999999.99 to 99999999.99.
QNUMERIC or DOUBLE PRECISION for money?
AAlways NUMERIC. DOUBLE PRECISION is binary floating point, cannot represent 0.1 exactly and drifts so totals stop reconciling. MONEY is also fixed-point but hard-wired to a currency format, which does not suit multi-currency use.
Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

Content reviewed by MOTO · Found an error? Report it

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏