1

I add trying to add a method to be the defualt value of an existing SQL Table Column:

 ALTER TABLE Category ALTER COLUMN category_course 
   CONSTRAINT cat_other_course DEFAULT otherCourse();

However I keep getting this error:

ERROR:  syntax error at or near "CONSTRAINT"
LINE 2: ALTER TABLE Category ALTER COLUMN category_course CONSTRAINT...
                                                      ^
********** Error **********

ERROR: syntax error at or near "CONSTRAINT"
SQL state: 42601

NB: Yes, Category (table) category_course (column) and otherCourse() (function) all exist.

1

1 Answer 1

1

You need to add SET before DEFAULT. Hope this helps.

ALTER TABLE Category ALTER COLUMN category_course 
CONSTRAINT cat_other_course SET DEFAULT otherCourse();
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.