|
Posted by Rik on 07/25/07 02:35
On Wed, 25 Jul 2007 03:51:55 +0200, René Vaessen
<rene100m..nospam@yahoo.com> wrote:
> <laredotornado@zipmail.com> schreef in bericht
> news:1184777424.702095.282450@z24g2000prh.googlegroups.com...
>> Hi,
>>
>> I'm using php 4.4.4 with MySQL 5.0 on Linux. Short of dropping the
>> database, which my user does not have privileges to, what is the
>> simplest way to purge all data from the db? By this I mean not only
>> deleting data from tables but also the tables themselves?
>>
>> Thanks, - Dave
>>
> Try this script
>
> $db=mysql_connect($host,$user,$pass) or die ("verbinding mislukt");
> mysql_select_db($datab,$db);
>
> $blaat = mysql_list_tables ($datab);
> $tbl = array();
>
> while ($row = mysql_fetch_row($blaat))
> $tbl[] = $row[0];
>
> $dit = 'DROP TABLE ';
> for ($a=0; $a < count($tbl); $a++) {
> $dit .= '`'.$tbl[$a].'`';
> if ($a < (count($tbl) - 1))
> $dit .= ', ';
> }
>
> $exec = mysql_query($dit) or die (mysql_error());
Hmm, and how would we surpress foreign key constraints before dropping
tables? This script might fail miserably there...
--
Rik Wasmus
Navigation:
[Reply to this message]
|