change from vachar to integer

teera
teera used Ask the Experts™
on
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;
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
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.
Commented:
ALTER TABLE billdetail
        ALTER COLUMN masterid TYPE INT USING masterid::integer;



I try loke that it work
If issue is resolved, I suggest you may please formally close the question.

Author

Commented:
i try it work

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial