Jump to content


Photo

How to drop all tables from db?


  • Please log in to reply
4 replies to this topic

#1 chriss

chriss
  • Members
  • PipPip
  • Member
  • 10 posts
  • LocationZG, Poland

Posted 04 October 2003 - 10:36 AM

Topic

#2 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,016 posts

Posted 04 October 2003 - 02:13 PM

Quickest way is drop database then recreate it.
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#3 chriss

chriss
  • Members
  • PipPip
  • Member
  • 10 posts
  • LocationZG, Poland

Posted 05 October 2003 - 08:48 AM

I understand, but I have no permission to create/drop db.

#4 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,016 posts

Posted 05 October 2003 - 09:15 AM

[php:1:c425fae520]<?php
$db_name = \'your db name\' ;

$cnx = mysql_connect(\'host\' , \'user\' , \'pwd\');
mysql_select_db($db_name);
$res = mysql_list_tables($db_name);
while ($row = mysql_fetch_row($res)) {
$table = $row[0];
echo \"Dropping $table <br>\";
mysql_query(\"DROP TABLE $table\");
}
?>[/php:1:c425fae520]

hth
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#5 chriss

chriss
  • Members
  • PipPip
  • Member
  • 10 posts
  • LocationZG, Poland

Posted 05 October 2003 - 09:20 AM

Thank You very much! :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users