Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » ElevateDB Technical Support » Support Forums » ElevateDB SQL » View Thread |
Messages 1 to 2 of 2 total |
ADD IF NOT EXISTS |
Tue, Dec 17 2013 11:03 AM | Permanent Link |
Antonio Marques | Hello! I have a question that is probably super easy to answer...
In my company we are developing a new version of our software and we are adding some foreign keys on the database. We made a script to perform all the changes needed. But we are not sure of all the changes so we have a button on the main form that we click to convert the current database by running the script. The problem is, when we run the script twice on the same database (when we add a new key for example) the execution fails because some of the keys are already there. Is there a way to add a key only if that key does not exists yet? ALTER TABLE myTable ADD IF NOT EXISTS CONSTRAINT "frg_key" FOREIGN KEY ... If not, how do I check for a foreign key on a script? Thank you! |
Tue, Dec 17 2013 3:46 PM | Permanent Link |
Uli Becker | Antonio,
> If not, how do I check for a foreign key on a script? select * from information.constraints where tablename = 'MyTable' Uli |
This web page was last updated on Sunday, May 5, 2024 at 10:18 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |