SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: Drop all tables with some prefix

  1. #1
    SitePoint Addict bimalpoudel's Avatar
    Join Date
    Feb 2009
    Location
    Kathmandu, Nepal
    Posts
    260
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Drop all tables with some prefix

    What would be the corresponding SQL for:
    Code:
    DROP TABLES LIKE 'test_%';
    I just want to delete all the tables that have 'test_' as a prefix.
    The current one does not work. It is a sample only to let you know what I wanted.
    Bimal Poudel @ Sanjaal Framework » over Smarty Template Engine
    ASKING INTERESTING QUESTIONS ON SITEPOINT FOURM

    Hire for coding support - PHP/MySQL

  2. #2
    SQL Consultant silver trophybronze trophy
    SitePoint Award Recipient r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    38,462
    Mentioned
    35 Post(s)
    Tagged
    1 Thread(s)
    run this --
    Code:
    SELECT CONCAT('DROP TABLE ',table_name,';')
      FROM information_schema.tables
     WHERE table_name LIKE 'm%'
    copy/paste the output and run that
    r937.com | rudy.ca | Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

Tags for this Thread

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
  •