Reputation: 12579
I am trying to alter a column data type in SQL but it gives me missing keyword error. I have looked at how to change a column in several places and they all gave me this piece of query:
I am using this:
ALTER TABLE CARD
MODIFY COLUMN Charged NUMBER(4,2);
Upvotes: 0
Views: 3734
Reputation: 755064
The COLUMN keyword is superfluous — this should work:
ALTER TABLE Card MODIFY Charged NUMBER(4,2)
Interestingly, standard SQL does not support MODIFY (which I did not know until I went to check the SQL Syntax). According to the SQL standard (ISO/IEC 9079-2:2003), you can write:
<alter column definition>
(p572)Change a column and its definition.
<alter column definition> ::= ALTER [ COLUMN ] <column name> <alter column action>
<alter column action> ::=
<set column default clause>
| <drop column default clause>
| <add column scope clause>
| <drop column scope clause>
| <alter identity column specification>
(and in SQL 2003, MODIFY
is not an SQL keyword). In this formulation, the keyword COLUMN
is permitted but is optional. It also does not seem to allow changing the type of the column, unlike 'real' DBMS.
Upvotes: 3
Reputation: 9618
Don't use "column" as a keyword:
ALTER TABLE card
MODIFY charged NUMBER(4,2);
Upvotes: 0
Reputation: 425418
You are missing brackets and you should omit the word COLUMN
:
ALTER TABLE CARD MODIFY ( Charged NUMBER(4,2));
See this documentation for examples of how to modify columns.
Upvotes: 0