Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I have a table in PostgreSQL where one column "vat" has type money but I would like to alter it to decimal instead.

How can I do it?

I tried with:

alter table my_table alter column vat type decimal;

But I get this error:

ERROR:  column "vat" cannot be cast to type numeric

Any suggestions?

share|improve this question
add comment

1 Answer 1

up vote 3 down vote accepted

Try providing USING clause as described in docs:

A USING clause must be provided if there is no implicit or assignment cast from old to new type.

share|improve this answer
    
Por ejemplo: alter table my_table alter column vat type decimal using vat::decimal; –  Scott Marlowe Sep 26 '11 at 20:28
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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