SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict jasongr's Avatar
    Join Date
    Jul 2004
    Location
    usa
    Posts
    371
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    perform alter table only if a table exists

    Hi people

    I need to run a batch of "Alter table" statements on a set of database tables.
    However, some of the databases may not exist, and even if they exist, the specific table might not exist.

    Alter table only works if the table exists.
    Is there a way to tell MySQL to execute the "Alter table" statement only if the database and table exist?
    If so, how?

    regards
    Jason

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,276
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    i don't think there is

    i'm just curious, but under what circumstances would you want to alter a table that doesn't exist? don't you know your own application?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •