문제

I tried to change precision like this:

ALTER Table account_invoice ALTER amount_total SET NUMERIC(5);

But I get syntax error, so I'm clearly doing something wrong. What is the right syntax to change precision of numeric in PostgreSQL?

도움이 되었습니까?

해결책

Try this:

ALTER Table account_invoice ALTER COLUMN amount_total TYPE DECIMAL(10,5);

DECIMAL(X, Y) -> X represents full length and Y represents precision of the number.

다른 팁

You can use this:

ALTER Table account_invoice ALTER amount_total SET DATA TYPE NUMERIC(5,Y);

where Y is your required level of precision.

You need to ue the TYPE keyword after the column name, not SET

ALTER Table account_invoice ALTER amount_total TYPE NUMERIC(5);

See the docs: ALTER TABLE

Example on SQL Fiddle

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top