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...
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
3 Answers
You don't need the "column" word in there, so it's:
ALTER TABLE test_id
ADD xml_column xmltype;
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
.
.
.
);