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.

Riko Hamblin
  • 71
  • 10

1 Answers1

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();
Rob Blagg
  • 260
  • 4
  • 13