Dropping all tables in a database?
Dropping all tables in a database?
am 18.07.2007 18:50:24 von laredotornado
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
Re: Dropping all tables in a database?
am 18.07.2007 22:17:59 von unknown
Post removed (X-No-Archive: yes)
Re: Dropping all tables in a database?
am 24.07.2007 23:59:22 von zac.carey
On 18 Jul, 17:50, "laredotorn...@zipmail.com"
wrote:
> 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
Just ask the person with the privileges to do it for you.
Re: Dropping all tables in a database?
am 25.07.2007 03:51:55 von rene100m..nospam
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());
Grtz,
René
Re: Dropping all tables in a database?
am 25.07.2007 04:35:32 von luiheidsgoeroe
On Wed, 25 Jul 2007 03:51:55 +0200, René Vaessen
wrote:
> 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