Cannot alter column in existing table in java Derby database

时光怂恿深爱的人放手 提交于 2019-12-08 02:03:51

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!