Add Column in Oracle Table

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
0

3 Answers

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

ALTER TABLE test_id ADD xml_column xmltype;

0

In addition,

you can add multiple columns at the same time with:

ALTER TABLE table_name ADD (column1 VARCHAR(40), column2 Date, column3 Number);

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
    .
    .
    .
);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Chloe Bennett

Chloe Bennett

Culture, Media & Entertainment Columnist

Chloe Bennett explores the intersection of pop culture, streaming entertainment, digital trends, and contemporary lifestyle. Her weekly commentary reaches thousands of culture enthusiasts.

Share this article
Twitter Facebook Pinterest