Hi Carlos!

> I was wondering how I could go about dropping all existing tables from a
> database?  Rather than using a DROP TABLE that lists each table I wish to
> drop is there not some way to drop all existing tables in a database?  Even
> if I cannot remember all the table names?

Mysqldump is very cool for getting information about a current db. This
line will grab a list of all tables in a db.  Redirect the output to a
file. Edit the file to add 'drop table ' to the start of each line and
'mysql -p [database] < [script file]'.

It's gonna wrap here but it's all one command line.

mysqldump -p [db] |grep "CREATE TABLE " |sed -e 's/CREATE TABLE //' |sed
-e 's/ (//'

Or you can do whatever you like, the point is that mysqldump can supply
the information you need. The seds just strip off the chars you don't need
from the dump.

Have a :) day!

jb

-- 
jim barchuk
[EMAIL PROTECTED]



---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to