How to duplicate a table complete with indexes? #

2002-02-12 Thread BD

At 10:34 AM 2/8/2002 , you wrote:

Quite often I'd like to duplicate an existing table using SQL. Normally I'd 
do a

create table NewTable select * from OldTable;

and if I don't want any data transferred I'll slap on a Limit 0 on the end
of the statement.

This works fine except it doesn't create any indexes that OldTable had. Is
there a generic way to duplicate a table that includes the indexes? I don't 
want to have to manually create indexes for it.

TIA

Brent


-
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: How to duplicate a table complete with indexes? #

2002-02-12 Thread Paul DuBois

At 13:22 -0600 2/8/02, BD wrote:
At 10:34 AM 2/8/2002 , you wrote:

Quite often I'd like to duplicate an existing table using SQL. 
Normally I'd do a

create table NewTable select * from OldTable;

and if I don't want any data transferred I'll slap on a Limit 0 on the end
of the statement.

This works fine except it doesn't create any indexes that OldTable had. Is
there a generic way to duplicate a table that includes the indexes? 
I don't want to have to manually create indexes for it.

Not using just SQL, no.  In a program, you can get the output from a
SHOW CREATE TABLE statement, perform a substitution to change the
table name, then execute the statement.  That will create a copy (empty) that
includes the indexes.


TIA

Brent


-
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: Re: How to duplicate a table complete with indexes? #

2002-02-12 Thread Brian Reichert

On Fri, Feb 08, 2002 at 09:09:39PM +0100, [EMAIL PROTECTED] wrote:
 Your message cannot be posted because it appears to be either spam or
 simply off topic to our filter. To bypass the filter you must include
 one of the following words in your message:
 
 sql,query

This 'anti-spam' measure, is kinda lame, I must say.  (Picture that
said in an Ed Grimley voice.  If you understand _that_, shame on
you! :)

 If you just reply to this message, and include the entire text of it in the
 reply, your reply will go through. However, you should
 first review the text of the message to make sure it has something to do
 with MySQL. Just typing the word MySQL once will be sufficient, for example.
 
 You have written the following:
 
 On Fri, Feb 08, 2002 at 01:22:08PM -0600, BD wrote:
  This works fine except it doesn't create any indexes that OldTable had. Is
  there a generic way to duplicate a table that includes the indexes? I don't 
  want to have to manually create indexes for it.
 
 What's wrong with outright copying the files associated with the
 table?  (Assuming the table's not in use).  I would _assume_ that
 this would work; i havent' tested it, of course...
 
  TIA
  
  Brent
 
 -- 
 Brian 'you Bastard' Reichert  [EMAIL PROTECTED]
 37 Crystal Ave. #303  Daytime number: (603) 434-6842
 Derry NH 03038-1713 USA   Intel architecture: the left-hand path
 

-- 
Brian 'you Bastard' Reichert[EMAIL PROTECTED]
37 Crystal Ave. #303Daytime number: (603) 434-6842
Derry NH 03038-1713 USA Intel architecture: the left-hand path

-
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: How to duplicate a table complete with indexes? #

2002-02-12 Thread Rafal Jank

 
 Quite often I'd like to duplicate an existing table using SQL. Normally I'd 
 do a
 
 create table NewTable select * from OldTable;
 
 and if I don't want any data transferred I'll slap on a Limit 0 on the end
 of the statement.
 
 This works fine except it doesn't create any indexes that OldTable had. Is
 there a generic way to duplicate a table that includes the indexes? I don't 
 want to have to manually create indexes for it.
take output from 
show create table OldTable;
 change the name of the table to New Table and, if you want to transfer data do insert 
into NewTable as select * from OldTable;

-- 
_/_/  _/_/_/  - Rafa Jank [EMAIL PROTECTED] -
 _/  _/  _/  _/   _/ Wirtualna Polska SA   http://www.wp.pl 
  _/_/_/_/  _/_/_/ul. Traugutta 115c, 80-237 Gdansk, tel/fax. (58)5215625
   _/  _/  _/ ==*  http://szukaj.wp.pl *==--

-
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: Re: How to duplicate a table complete with indexes? #

2002-02-08 Thread Brian Reichert

On Fri, Feb 08, 2002 at 09:09:39PM +0100, [EMAIL PROTECTED] wrote:
 Your message cannot be posted because it appears to be either spam or
 simply off topic to our filter. To bypass the filter you must include
 one of the following words in your message:
 
 sql,query

This 'anti-spam' measure, is kinda lame, I must say.  (Picture that
said in an Ed Grimley voice.  If you understand _that_, shame on
you! :)

 If you just reply to this message, and include the entire text of it in the
 reply, your reply will go through. However, you should
 first review the text of the message to make sure it has something to do
 with MySQL. Just typing the word MySQL once will be sufficient, for example.
 
 You have written the following:
 
 On Fri, Feb 08, 2002 at 01:22:08PM -0600, BD wrote:
  This works fine except it doesn't create any indexes that OldTable had. Is
  there a generic way to duplicate a table that includes the indexes? I don't 
  want to have to manually create indexes for it.
 
 What's wrong with outright copying the files associated with the
 table?  (Assuming the table's not in use).  I would _assume_ that
 this would work; i havent' tested it, of course...
 
  TIA
  
  Brent
 
 -- 
 Brian 'you Bastard' Reichert  [EMAIL PROTECTED]
 37 Crystal Ave. #303  Daytime number: (603) 434-6842
 Derry NH 03038-1713 USA   Intel architecture: the left-hand path
 

-- 
Brian 'you Bastard' Reichert[EMAIL PROTECTED]
37 Crystal Ave. #303Daytime number: (603) 434-6842
Derry NH 03038-1713 USA Intel architecture: the left-hand path

-
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