Postgresql – How to alter column from float(8) to numeric(64,8)

postgresql

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!

Best Answer

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