Add column in Oracle table
Asked Answered
F

3

31

I'm trying to add an XMLType column into a table, but it returns an error. Why?

This is the query:

alter table TEST_ID add column xml_column xmltype;

It returns the error:

[SQL] alter table TEST_ID add column xml_column xmltype
[Err] ORA-00904: : invalid identifier
Frankel answered 22/12, 2014 at 6:12 Comment(0)
B
42

You don't need the "column" word in there, so it's:

ALTER TABLE test_id ADD xml_column xmltype;

Billposter answered 22/12, 2014 at 6:19 Comment(0)
H
22

In addition,

you can add multiple columns at the same time with:

ALTER TABLE table_name ADD (column1 VARCHAR(40), column2 Date, column3 Number);
Hooligan answered 2/11, 2017 at 10:49 Comment(0)
S
3

There is a syntax error- key COLUMN is not required before column name :

1. To add a single column:

ALTER TABLE TABLE_NAME ADD 
    COLUMN_NAME DATA_TYPE;

2. To add multiple columns:

ALTER TABLE TABLE_NAME ADD (
    COLUMN_NAME1 DATA_TYPE1,
    COLUMN_NAME2 DATA_TYPE2, 
    COLUMN_NAME3 DATA_TYPE3
    .
    .
    .
);
Stambul answered 11/2, 2021 at 12:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.