5

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.

2
  • What is the column name? Commented Mar 7, 2018 at 16:53
  • type, its in quotes because of type is reserved key Commented Mar 7, 2018 at 16:56

1 Answer 1

12
create table user_template (field1 varchar(255));
ALTER TABLE user_template ALTER COLUMN field1 TYPE varchar(15);

dbfiddle here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.