logo logo

 Back to main page

The NWNX Community Forum

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Adding columns with SQL

 
Post new topic   Reply to topic    nwnx.org Forum Index -> Database related
View previous topic :: View next topic  
Author Message
Alderaan



Joined: 29 Jan 2005
Posts: 3

PostPosted: Sun Mar 13, 2005 14:21    Post subject: Adding columns with SQL Reply with quote

I have a table called "Table", I want SQL to add a column "C1" (INT(11)) if "Table" does not contains already "C1". IF "Table" already contains "C1", then do nothing.

How can I do that under SQL?

Thanks
Back to top
View user's profile Send private message
NoMercy



Joined: 03 Jan 2005
Posts: 123
Location: UK

PostPosted: Sun Mar 13, 2005 15:12    Post subject: Reply with quote

ALTER TABLE 'Table' ADD C1 INT(11);

I can't think of any nice way of testing if the column exists, but if it does this statement will in theory just generate an error.
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Database related All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group