-2

When i try to drop a column using the below command,

alter table <table_name> drop <column_name>;

am getting "missing keyword" error.

Getting the same error when am using column keyword also as below,

alter table <table_name> drop column <column_name>;
Lalit Kumar B
  • 47,486
  • 13
  • 97
  • 124
Ramanathan K
  • 1,829
  • 3
  • 13
  • 8

2 Answers2

1

alter table <table_name> drop column <column_name> works perfectly.

For example,

SQL> create table t(id number, text varchar2(10));

Table created.

SQL> desc t;
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 ID                                                 NUMBER
 TEXT                                               VARCHAR2(10)

SQL> alter table t drop column text;

Table altered.

SQL> desc t;
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 ID                                                 NUMBER

SQL>
Lalit Kumar B
  • 47,486
  • 13
  • 97
  • 124
0

You can do

ALTER TABLE table1 DROP COLUMN column1;

or

ALTER TABLE table1 DROP (column1, column2, ...);

or even

ALTER TABLE table1 SET UNUSED (column1);
ALTER TABLE table1 DROP UNUSED COLUMNS;

Here is a SQLFiddle demo

peterm
  • 91,357
  • 15
  • 148
  • 157