Drop multiple tables with same prefix

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hsriat
    Recognized Expert Top Contributor
    • Jan 2008
    • 1653

    Drop multiple tables with same prefix

    How can I drop all the tables from the database which start with a common prefix (say t1_)?

    Query or PHP code... any simple solution?
  • mwasif
    Recognized Expert Contributor
    • Jul 2006
    • 802

    #2
    You can drop tables like this. But you can select all tables starting with t1 with the following query
    [CODE=mysql]SHOW TABLES LIKE 't1%'[/CODE]

    Use this query in PHP to get all the table and loop through them to drop one table at a time.

    Comment

    • hsriat
      Recognized Expert Top Contributor
      • Jan 2008
      • 1653

      #3
      Thank You mwasif... this worked good and saved my time. :)

      Comment

      • mwasif
        Recognized Expert Contributor
        • Jul 2006
        • 802

        #4
        You are welcome.

        Comment

        Working...