Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

MrThePlague's avatar

PostgreSQL `numeric` column without explicit precision or scale?

PostgreSQL supports a numeric column that doesn't specify an explicit precision or scale, allowing values of any precision, but it looks as though specifying a migration like the following defaults to using scale of 8 and a precision of 2:

$table->decimal('column_name`);

Is there a way to correctly set a column type of simply numeric?

0 likes
1 reply
sr57's avatar

PostgreSQL supports a numeric column that doesn't specify an explicit precision or scale,

Yes

allowing values of any precision,

No

There is default values, up to 131072 digits before the decimal point; up to 16383 digits after the decimal point see https://www.postgresql.org/docs/9.1/datatype-numeric.html

So you have to define your default values less or equal to the above ones in your decimal declaration. I never tested the maximum, let us know if you do.

Please or to participate in this conversation.