I want to convert column type from varchar to integer in postgresql
ALTER TABLE billdetail ALTER COLUMN masterid TYPE integer;
gives
[Err] ERROR: column "masterid" cannot be cast automatically to type integer
HINT: You might need to specify "USING masterid::integer".
while
ALTER TABLE billdetail USING masterid::integer;
gives
[Err] ERROR: syntax error at or near "USING"
LINE 1: ALTER TABLE billdetail USING masterid::integer;
How can I fix this problem?
Try,
ALTER TABLE billdetail
ALTER COLUMN masterid TYPE INT USING masterid::integer;
You forgot to alter the column.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With