Re: Create table if not exists from mysqldump?

2002-10-04 Thread swati sandhya

Hi,

Do u mean when u take a dump you need to add before
each table drop table if exists

then here is the command.

mysqldump -uusername -p -hhostname
--add-drop-table databasename tablename  test.sql

regards,
Praveen
--- John Kelly [EMAIL PROTECTED] wrote:
 Hi, I am trying to use mysqldump to dump the
 structure of a single database
 and want the output to make create table commands
 that include the IF NOT
 EXISTS switch so that when the file is imported into
 an existing database it
 does not write over tables with the same name. Does
 anyone know if this is
 possible with mysqldump and if so what option
 achieves this? Thanks.
 

-
 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
 


__
Do you Yahoo!?
New DSL Internet Access from SBC  Yahoo!
http://sbc.yahoo.com

-
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




Re: Create table if not exists from mysqldump?

2002-10-04 Thread Gerald R. Jensen

Or your could ...

mysqldump -uusername -p -hhostname --all --add-drop-table --add-locks --
complete-insert --compress --extended-insert --flush-logs --force --opt --ve
rbose --databases databasename tablename  test.sql


- Original Message -
From: swati sandhya [EMAIL PROTECTED]
To: John Kelly [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Friday, October 04, 2002 5:19 AM
Subject: Re: Create table if not exists from mysqldump?


Hi,

Do u mean when u take a dump you need to add before
each table drop table if exists

then here is the command.

mysqldump -uusername -p -hhostname
--add-drop-table databasename tablename  test.sql

regards,
Praveen
--- John Kelly [EMAIL PROTECTED] wrote:
 Hi, I am trying to use mysqldump to dump the
 structure of a single database
 and want the output to make create table commands
 that include the IF NOT
 EXISTS switch so that when the file is imported into
 an existing database it
 does not write over tables with the same name. Does
 anyone know if this is
 possible with mysqldump and if so what option
 achieves this? Thanks.


-
 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



__
Do you Yahoo!?
New DSL Internet Access from SBC  Yahoo!
http://sbc.yahoo.com

-
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




-
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




re: Create table if not exists from mysqldump?

2002-10-04 Thread Victoria Reznichenko

John,
Friday, October 04, 2002, 6:41:46 AM, you wrote:

JK Hi, I am trying to use mysqldump to dump the structure of a single database
JK and want the output to make create table commands that include the IF NOT
JK EXISTS switch so that when the file is imported into an existing database it
JK does not write over tables with the same name. Does anyone know if this is
JK possible with mysqldump and if so what option achieves this? Thanks.

You can't.

You can add DROP TABLE before each CREATE table statement using
--add-drop-table option. You can run mysql with --force option when
you restore tables from dump file.


-- 
For technical support contracts, goto https://order.mysql.com/?ref=ensita
This email is sponsored by Ensita.net http://www.ensita.net/
   __  ___ ___   __
  /  |/  /_ __/ __/ __ \/ /Victoria Reznichenko
 / /|_/ / // /\ \/ /_/ / /__   [EMAIL PROTECTED]
/_/  /_/\_, /___/\___\_\___/   MySQL AB / Ensita.net
   ___/   www.mysql.com





-
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




Re: Create table if not exists from mysqldump?

2002-10-04 Thread Clayburn W. Juniel, III


On Thursday, Oct 3, 2002, at 20:41 America/Phoenix, John Kelly wrote:

 Hi, I am trying to use mysqldump to dump the structure of a single 
 database
 and want the output to make create table commands that include the IF 
 NOT
 EXISTS switch so that when the file is imported into an existing 
 database it
 does not write over tables with the same name. Does anyone know if 
 this is
 possible with mysqldump and if so what option achieves this? Thanks.

add the option -n or --no-create-db.   This will add IF NOT CREATE to 
the sql.

--
Clayburn W. Juniel, III -- Effective Software Solutions
Phone: (602) 326-7707Mobile: (602)326-7707
Email: [EMAIL PROTECTED]
http://EffectiveSoftwareSolutions.com
--


-
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




Fwd: Create table if not exists from mysqldump?

2002-10-04 Thread Clayburn W. Juniel, III



Begin forwarded message:

From: Clayburn W. Juniel, III [EMAIL PROTECTED]
Date: Fri Oct 4, 2002  10:24:06 America/Phoenix
To: Clayburn W. Juniel, III [EMAIL PROTECTED]
Subject: Re: Create table if not exists from mysqldump?


On Friday, Oct 4, 2002, at 08:48 America/Phoenix, Clayburn W. Juniel, 
III wrote:


 On Thursday, Oct 3, 2002, at 20:41 America/Phoenix, John Kelly wrote:

 Hi, I am trying to use mysqldump to dump the structure of a single 
 database
 and want the output to make create table commands that include the IF 
 NOT
 EXISTS switch so that when the file is imported into an existing 
 database it
 does not write over tables with the same name. Does anyone know if 
 this is
 possible with mysqldump and if so what option achieves this? Thanks.

 add the option -n or --no-create-db.   This will add IF NOT CREATE to 
 the sql.

Oops!  That's not correct.  That only works on creating the database 
not the table.  But since this is only a text file, what you can do is 
use whatever program you have available and change every occurrence of 
CREATE TABLE to CREATE TABLE IF NOT EXISTS.  If someone sees a reason 
why this won't work, please let me know.

--
Clayburn W. Juniel, III -- Effective Software Solutions
Phone: (602) 326-7707Mobile: (602)326-7707
Email: [EMAIL PROTECTED]
http://EffectiveSoftwareSolutions.com
--


-
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




Create table if not exists from mysqldump?

2002-10-04 Thread John Kelly

Thanks for all the responses on how to import a dump file that will not
write over existing tables and not stop with an error on existing tables -
in other words just add missing tables. As Victoria pointed out, there is no
option in mysqldump to add the appropriate create table option [IF NOT
EXISTS] but one can add the --force option when importing the dump file back
in with mysql. This causes mysql to ignore the error generated when it comes
across a table that already exists and it will continue on adding any tables
that are missing. Without it, mysql will stop on the first table that
already exists with an error. An alternative solution is running a script on
the dump file to replace all occurrences of  CREATE TABLE  with  CREATE
TABLE IF NOT EXISTS  as suggested by Clayburn. Thanks again!

John

-
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




Create table if not exists from mysqldump?

2002-10-03 Thread John Kelly

Hi, I am trying to use mysqldump to dump the structure of a single database
and want the output to make create table commands that include the IF NOT
EXISTS switch so that when the file is imported into an existing database it
does not write over tables with the same name. Does anyone know if this is
possible with mysqldump and if so what option achieves this? Thanks.

-
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