<?xml version="1.0" encoding="windows-1252"?>
<node id="994591" title="Re^3: Deleting all from all tables in MYSQL" created="2012-09-20 02:55:41" updated="2012-09-20 02:55:41">
<type id="11">
note</type>
<author id="200365">
Tux</author>
<data>
<field name="doctext">
&lt;p&gt;In that case, dropping the database and recreating it is most likely the fastest solution. Database drops in PostgreSQL and MySQL/MariaDB are almost instant. In Oracle it takes ages to (re)create a database.&lt;/p&gt;
&lt;p&gt;To get all tables, why not use the [https://metacpan.org/module/DBI#89|DBI::tables]? That way you don't have to dig into database specific calls.&lt;/p&gt;
&lt;p&gt;If you still want to delete in stead of re-create, why use a &lt;c&gt;prepare/execute&lt;/c&gt; combo instead of just [https://metacpan.org/module/DBI#67|do]?&lt;/p&gt;
&lt;code&gt;    $dbh-&gt;do ("truncate table $_") for $dbh-&gt;tables (undef, undef, undef, "TABLE");&lt;/code&gt;
&lt;p&gt;or&lt;/p&gt;
&lt;code&gt;    $dbh-&gt;do ("delete   from  $_") for $dbh-&gt;tables (undef, undef, undef, "TABLE");&lt;/code&gt;
&lt;p&gt;In other databases, you could use &lt;c&gt;delete from table cascade&lt;/c&gt;, but iirc that syntax is not supported by mysql where you'd have to create the table to know about cascading deletes.&lt;/p&gt;
&lt;!-- Node text goes above. Div tags should contain sig only --&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-200365"&gt;
&lt;br /&gt;
Enjoy, Have FUN! H.Merijn
&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
994479</field>
<field name="parent_node">
994505</field>
</data>
</node>
