I have table in production which has column type character varying(255);
All rows has entry in that column no longer than 15 characters and never will be larger as well. I decide to reduce its size to 15 characters with following command which I found on sof:
ALTER TABLE user_template ALTER COLUMN "TYPE" character varying(15);
I got following error:
ERROR: syntax error at or near "character"
LINE 1: ...LTER TABLE user_template ALTER COLUMN "type" character ...
^
Can you help me to fix it? Thanks.
create table user_template (field1 varchar(255));
✓
ALTER TABLE user_template ALTER COLUMN field1 TYPE varchar(15);
✓
dbfiddle here
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