+ Reply to Thread
Results 1 to 4 of 4

Thread: Drop table if exists

  1. #1
    fake01 is offline x10Hosting Member fake01 is an unknown quantity at this point
    Join Date
    Dec 2009
    Posts
    24

    Drop table if exists

    I was just wondering how I would go about dropping a table if it exists. I don't have much knowledge of MySQL and have been using PHPMyAdmin to create, insert, edit, delete and drop tables.

    But I'm currently creating a .sql script which will create and insert all the default tables and data and want to drop tables if they already exist. So how will I achieve this?

  2. #2
    diabolo's Avatar
    diabolo is offline Community Advocate diabolo is on a distinguished road
    Join Date
    Nov 2007
    Location
    Jersey Shore
    Posts
    1,683

    Re: Drop table if exists

    simple.
    Code:
    DROP TABLE IF EXISTS `Table_I_Want_To_Drop`

  3. #3
    fake01 is offline x10Hosting Member fake01 is an unknown quantity at this point
    Join Date
    Dec 2009
    Posts
    24

    Re: Drop table if exists

    Cheers

    But is it:
    PHP Code:
    DROP TABLE IF EXISTS `Table_I_Want_To_Drop
    or
    PHP Code:
    DROP TABLE IF EXISTS Table_I_Want_To_Drop
    Or can both be used?

  4. #4
    diabolo's Avatar
    diabolo is offline Community Advocate diabolo is on a distinguished road
    Join Date
    Nov 2007
    Location
    Jersey Shore
    Posts
    1,683

    Re: Drop table if exists

    both can be used.
    I just like to use `` to refer to table names

+ Reply to Thread

Similar Threads

  1. mysql table if not exists
    By garrensilverwing in forum Programming Help
    Replies: 9
    Last Post: 07-16-2009, 06:31 AM
  2. check if mysql database table exists
    By daileyj2 in forum Programming Help
    Replies: 3
    Last Post: 08-14-2008, 08:21 PM
  3. MysQL Query for Master table & child table
    By phpasks in forum Programming Help
    Replies: 8
    Last Post: 08-07-2008, 08:07 AM
  4. Table does not exists
    By rttsrc1 in forum Programming Help
    Replies: 3
    Last Post: 07-06-2008, 10:44 AM
  5. Table inside table
    By wizeman in forum Tutorials
    Replies: 4
    Last Post: 07-11-2005, 05:56 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers