troubleshooting Question

check if table/record exists in mysql

Avatar of mikha
mikhaFlag for United States of America asked on
5 Comments1 Solution58 ViewsLast Modified:
I want to create scripts to create a database/schema and seed data in mysql as such, pseudo code below

if the table doesn't exits is true
    then create table

Note - I don't want to drop table before  creating it , just want to check if it exits or not ,

another way i was thinking was, which is less code , more like a try and catch block in other languages , such that if there is already a table by that name, it throws an exception and
i don't do anything .

try {

         create table MyTable

Catch {
              //do nothing

Also, if i version these scripts , such that

script 1
script 2
script 3,

is there a way, I can run this and make changes to my database from whatever folder i am in  , instead of having to copy the content of the scripts to the query window in mysql workbench
Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros