{"id":44,"date":"2006-11-10T22:06:53","date_gmt":"2006-11-10T22:06:53","guid":{"rendered":"http:\/\/thenoyes.com\/littlenoise\/?p=44"},"modified":"2015-10-14T11:22:09","modified_gmt":"2015-10-14T16:22:09","slug":"drop-all-tables","status":"publish","type":"post","link":"https:\/\/thenoyes.com\/littlenoise\/?p=44","title":{"rendered":"Drop all tables"},"content":{"rendered":"<p>Since there exists neither DROP TABLE * nor DROP TABLE WHERE name LIKE &#8216;something&#8217;, here are two ways to achieve the same:<\/p>\n<p>For version 5.0+:<\/p>\n<pre>mysql -N -e \"SELECT CONCAT('DROP TABLE ', GROUP_CONCAT(table_name), ';') FROM information_schema.tables WHERE table_schema = 'dbName'\" | mysql dbName<\/pre>\n<p><!--more--><\/p>\n<p>For any version on a platform with grep available:<\/p>\n<pre>mysqldump --add-drop-table -d dbName | grep -e \"DROP TABLE\" | mysql dbName<\/pre>\n<\/p>\n<p>For any version on Windows:<\/p>\n<pre>mysqldump --add-drop-table -d dbName | findstr \/B \"DROP TABLE\" | mysql dbName<\/pre>\n<\/p>\n<p>You can alter the WHERE clause of the first or the grep of the second to support whatever specifics you like, such as all the tables that have a common prefix.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Since there exists neither DROP TABLE * nor DROP TABLE WHERE name LIKE &#8216;something&#8217;, here are two ways to achieve the same: For version 5.0+: mysql -N -e &#8220;SELECT CONCAT(&#8216;DROP TABLE &#8216;, GROUP_CONCAT(table_name), &#8216;;&#8217;) FROM information_schema.tables WHERE table_schema = &#8216;dbName'&#8221; | mysql dbName<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[8],"tags":[],"class_list":["post-44","post","type-post","status-publish","format-standard","hentry","category-mysql-faq"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p2IBF1-I","jetpack_sharing_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/thenoyes.com\/littlenoise\/index.php?rest_route=\/wp\/v2\/posts\/44","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thenoyes.com\/littlenoise\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thenoyes.com\/littlenoise\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thenoyes.com\/littlenoise\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/thenoyes.com\/littlenoise\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=44"}],"version-history":[{"count":3,"href":"https:\/\/thenoyes.com\/littlenoise\/index.php?rest_route=\/wp\/v2\/posts\/44\/revisions"}],"predecessor-version":[{"id":419,"href":"https:\/\/thenoyes.com\/littlenoise\/index.php?rest_route=\/wp\/v2\/posts\/44\/revisions\/419"}],"wp:attachment":[{"href":"https:\/\/thenoyes.com\/littlenoise\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=44"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thenoyes.com\/littlenoise\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=44"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thenoyes.com\/littlenoise\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=44"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}