2

I am working on a website that store lots of numbers in a very specific precisions (8 digits). Most of the columns are using numeric(64,8), but I discovered that a handful are using float(8) instead, and it's causing a lot of computation issues.

How can I alter those float columns to numeric(64,8)? How do I cast the data?

Thanks!

1

1 Answer 1

3
ALTER TABLE your_table 
   ALTER COLUMN the_float_column TYPE numeric(64,8);

More details in the manual: http://www.postgresql.org/docs/current/static/sql-altertable.html

2
  • There is no need to specify any casting function using the keyword 'USING' ?
    – user33563
    Jan 30, 2014 at 8:38
  • 1
    @user33563: a cast is not necessary because those two types are "compatible".
    – user1822
    Jan 30, 2014 at 8:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.