Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialFabian Raschke
2,908 PointsHow to DROP several TABLES with a wildcard?
Hi,
I have a lot of tables in my DB that I want to delete. They all start with 'temp'.
How can I delete all of them at once?
3 Answers
Andrew McCormick
17,730 Pointsmaybe: DROP table WHERE table LIKE "temp%' ;
Fabian Raschke
2,908 PointsI am doing the Deep Dive "Database Foundations" with Andrew Chalkley (who is a great and funny tutor) but I haven't found a solution there. May anybody give me a hint?
Andrew Chalkley
Treehouse Guest TeacherI looked in the documentation and it doesn't look like it's possible.
You could use another programming language to do SHOW tables where Tables_in_<database_name_here> LIKE 'temp%'
and then cycle over them and drop each one.
Hope that helps.
Andrew
Fabian Raschke
2,908 PointsFabian Raschke
2,908 PointsNo, that doesn't work.