Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.
ALTER TABLE {abc_in} ADD COLUMN abcd_nid int(10) unsigned NOT NULL default '0' AFTER abcd_in

What if column abcd_nid already exists ? Will it be overwritten ? how can I insert new values into column ?

share|improve this question
    
which DBMS do you use? In DB2 you'll get an error message. You should try it out, if you can. Changing the values from default to something else can easily be done with "update {abc_in} set abcd_nid = ... where ..." –  kasia.b Sep 16 '13 at 13:07
2  
this is easily testable by creating a test database (which you should have on your development machine!) and executing the statement in your question twice. The 2nd time, you will receive an error explaining that you cannot add a field when it already exists. –  Max Vernon Sep 16 '13 at 14:47
add comment

1 Answer

You did not mention which database you are using, however trying to add a column that already exists will produce an error. All the databases that I have worked with require a column name to be unique within a table. (No room for two abcd_nid columns.)

To update the column you use the standard UPDATE command.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.