Figen Güngör
Figen Güngör

Reputation: 12579

Missing keyword error in Oracle

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

Answers (3)

Jonathan Leffler
Jonathan Leffler

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:

11.12 <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

BellevueBob
BellevueBob

Reputation: 9618

Don't use "column" as a keyword:

ALTER TABLE card
MODIFY charged NUMBER(4,2);

Upvotes: 0

Bohemian
Bohemian

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

Related Questions