Drop multiple databases?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John Sherling

    #1

    Drop multiple databases?

    I'm using 4.1.13a of mysql. Want to know if there's an easy way to dro
    pall databases that share a common prefix, using a single command. So
    if my databases are:

    uesr1_coolDB1
    user1_another_d b_2
    user1_db3

    I'd like to be able to drop them all with something like:

    DROP DATABASE user1_*;

    Possible? Other ways to do the same thing?

    Many thanks...

  • que

    #2
    Re: Drop multiple databases?

    no

    John Sherling íàïèñàâ:
    I'm using 4.1.13a of mysql. Want to know if there's an easy way to dro
    pall databases that share a common prefix, using a single command. So
    if my databases are:
    >
    uesr1_coolDB1
    user1_another_d b_2
    user1_db3
    >
    I'd like to be able to drop them all with something like:
    >
    DROP DATABASE user1_*;

    Possible? Other ways to do the same thing?

    Many thanks...

    Comment

    • Aggro

      #3
      Re: Drop multiple databases?

      John Sherling wrote:
      I'm using 4.1.13a of mysql. Want to know if there's an easy way to dro
      pall databases that share a common prefix, using a single command. So if
      my databases are:
      >
      uesr1_coolDB1
      user1_another_d b_2
      user1_db3
      >
      I'd like to be able to drop them all with something like:
      >
      DROP DATABASE user1_*;
      >
      Possible? Other ways to do the same thing?
      Not possible, but you could create a script that would first query
      tablenames, separate those you want to and create delete queries and
      execute them. It isn't that hard if you are working on Linux or similar
      platform and are experienced programmer, but if you are talking about
      20-50 tables, just do "show tables", copy-paste the result to an text
      editor and use search&replace to create delete queries and copy-paste
      back to console to execute.

      Comment

      Working...