change from vachar to integer

I want to convert column type from  to integer

ALTER TABLE billdetail ALTER COLUMN  masterid TYPE integer;

Open in new window

[Err] ERROR:  column "masterid" cannot be cast automatically to type integer
HINT:  You might need to specify "USING masterid::integer".

when I try
 ALTER TABLE billdetail USING masterid::integer; 

Open in new window

[Err] ERROR:  syntax error at or near "USING"
LINE 1: ALTER TABLE billdetail USING masterid::integer;
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Nitin SontakkeDeveloperCommented:
While I have virtually no knowledge of PostgreSQL, the typical approach is to add a new column with desired data type. Update it from the original column and then drop the original column. If you want identical name, you can also have your column renamed once the original one is dropped, I believe.
teeraAuthor Commented:
ALTER TABLE billdetail
        ALTER COLUMN masterid TYPE INT USING masterid::integer;

I try loke that it work

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Nitin SontakkeDeveloperCommented:
If issue is resolved, I suggest you may please formally close the question.
teeraAuthor Commented:
i try it work
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.