Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

delete tables with prefix

Status
Not open for further replies.

IDTstudios1

Programmer
Aug 8, 2004
72
US
How can i delete all of the table in a db with a certain prefix(ex. blah_)?

thanks
 
Can you tell us what database server you are talking about?
For MySQL:
The DROP TABLE syntax does not support wildcards, and I think that is good so - no dropped tables because of a typo.
I would suggest that you follow these steps:
1. List all table names that match the pattern 2. Concatenate those names with commas and fill it into the SQL statement "DROP TABLES".

This is the safe way to do what you want to achieve.
 
Sorry, I often to forget to specify wich db. I guess since i only work with mysql i forget there are others.

thanks for the help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top