Gossamer Forum
Home : General : Databases and SQL :

Drop tables if they exist, without --add-drop-tables?

Quote Reply
Drop tables if they exist, without --add-drop-tables?
Hi. I've created a MySQLDump of a quite large database, and am trying to re-import the data into it. When I created it, I didn't invoke the drop tables stuff with --add-drop-tables. Is there a way I can do this with 'mysql' ? i.e....

mysql --drop-tables -uxxx -pxxx DatabaseName < file.sql

... or is it a case of having to totally wipe the database, and re-doing it from scratch with the MySQLDump file? I'm hoping there is a different option to the latter Unsure

TIA

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] Drop tables if they exist, without --add-drop-tables? In reply to
You could open up the dump file and before every CREATE TABLE statement add a DROP TABLE IF EXISTS table_name statement.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Drop tables if they exist, without --add-drop-tables? In reply to
Its 1.8Gb in size Unsure

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] Drop tables if they exist, without --add-drop-tables? In reply to
Use TextPad to open the file, which can handle files past 2.0 GB.
========================================
Buh Bye!

Cheers,
Me
Quote Reply
Re: [Andy] Drop tables if they exist, without --add-drop-tables? In reply to
Create a drop.sql that just has the drop table statements, then run that one first, and then the other sql. Alternatively, join them together (cat main.sql >> drop.sql).

Cheers,

Alex
--
Gossamer Threads Inc.