Search code examples
javasqlderbyddl

Derby how to add NOT NULL constraint on an existing column


I have been searching for solutions to this, all what I have seen doesn't work, currently I am trying: ALTER TABLE INVOICE_RECORDS ALTER COLUMN SERIAL_NUMBER VARCHAR(10) NOT NULL but it doesn't work.

Error message is: java.sql.SQLSyntaxErrorException: Syntax error: Encountered "VARCHAR" at line 1, column 53.

I am running this in a JavaFX app.

I just want to add the NOT NULL constraint to the SERIAL_NUMBER column.


Solution

  • Based on Bryan Pendleton's comment I tried

    ALTER TABLE INVOICE_RECORDS ALTER COLUMN SERIAL_NUMBER NOT NULL
    

    ...and it worked for me. Removing VARCHAR(10) did the trick.

    Thanks Bryan!