Introduction
We use numeric and decimal precision to store numbers exactly, especially when we need to keep the right number of digits after the decimal point, like money or measurements.
NUMERIC(precision, scale)
DECIMAL(precision, scale)NUMERIC(5, 2)
DECIMAL(10, 4)
NUMERIC
CREATE TABLE prices ( item_id SERIAL PRIMARY KEY, price NUMERIC(6, 2) ); INSERT INTO prices (price) VALUES (1234.56), (78.9), (0.123); SELECT * FROM prices;
scale represent in a NUMERIC(10, 3) data type in PostgreSQL?NUMERIC(precision, scale), precision is total digits, scale is digits after decimal.price with 7 digits total and 2 digits after the decimal in PostgreSQL?NUMERIC(precision, scale) where precision >= scale.price NUMERIC(7,2) uses NUMERIC(7,2) which means 7 total digits, 2 after decimal.products(price NUMERIC(5,2)), what will be the stored value after inserting INSERT INTO products(price) VALUES (123.4567);?amount NUMERIC(4,2). You try to insert 999.99 but get an error. What is the problem?Pass the test and this pattern moves unknown