I get an error "incompatible types: bigint and character varying." but I know there usually is a trick to bypass this.
First, specify the name of the table to which the column you want to change belongs in the ALTER TABLE clause. Second, give the name of column whose data type will be changed in the ALTER COLUMN clause. Third, provide the new data type for the column after the TYPE keyword.
Character varying is the official type of SQL ANSI standard. It will support all SQL compliances. Character varying is most useful and important data type in PostgreSQL used without a length specifier.
The short answer: there is no difference. The long answer: CHARACTER VARYING is the official type name from the ANSI SQL standard, which all compliant databases are required to support. (SQL compliance Feature ID E021-02.) VARCHAR is a shorter alias which all modern databases also support.
alter table abc alter column def type varchar using def::varchar;
Seems to work fine in PG 9.0, but if not in your version you can always convert to text first:
select 1::bigint::text::varchar;
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