SQL Language (MOSC)

MOSC Banner

Handling error in alter table or create index statement if the column / index already exists

edited Aug 5, 2013 8:14PM in SQL Language (MOSC) 5 commentsAnswered

Hi

We have a process in place where we run a script on our database that includes adding new column to an existing table or creating a new index on existing table. The script output is written to a log file

for example

Alter table test add (zipcode  varchar2(5));

OR

Create index idx_test_zip on test (zipcode)


The problem is that if the column or the index exist, we get an error

ERROR at line 1:
ORA-01430: column being added already exists in table

ERROR at line 1:
ORA-00955: name is already used by an existing object


What we need is that if the column or index to be added already exists, the script

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center