问题
I am trying to alter my table by changing one of the columns in the table. But, I am encountering an error while I execute the following sql command -
ALTER TABLE WALLETUSER MODIFY WALLETUSERNAME VARCHAR NOT NULL;
The error i receive is -
Error code -1, SQL state 42X01: Syntax error: Encountered "MODIFY" at line 1, column 24.
Would appreciate any help.
回答1:
Try this instead:
ALTER TABLE WALLETUSER ALTER COLUMN WALLETUSERNAME NOT NULL;
Full syntax guide:
ALTER TABLE table-Name
{
ADD COLUMN column-definition |
ADD CONSTRAINT clause |
DROP [ COLUMN ] column-name [ CASCADE | RESTRICT ]
DROP { PRIMARY KEY | FOREIGN KEY constraint-name | UNIQUE constraint-name | CHECK constraint-name | CONSTRAINT constraint-name }
ALTER [ COLUMN ] column-alteration |
LOCKSIZE { ROW | TABLE }
}
column-definition
Simple-column-Name [ DataType ]
[ Column-level-constraint ]*
[ [ WITH ] DEFAULT DefaultConstantExpression | generation-clause ]
Source:
- Derby ALTER TABLE syntax
来源:https://stackoverflow.com/questions/13506777/cannot-alter-column-in-existing-table-in-java-derby-database