简体   繁体   中英

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.

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!

TutorialsPoint说要这样做:

ALTER TABLE INVOICE_RECORDS MODIFY SERIAL_NUMBER VARCHAR(10) NOT NULL

尝试这个。

ALTER TABLE INVOICE_RECORDS ADD CONSTRAINT INVOICE_SERIAL_NUM NOT NULL(SERIAL_NUMBER);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM