Cloning a table with different column names

2007-02-05 Thread Tim Johnson
Hello:

I have a need to create two tables from imported data.
The only difference between the tables is the column names.

The data will be the same.

Can anyone propose a mysql method to create a new table
from an existing table with new column names?

thanks
tim
-- 
Tim Johnson [EMAIL PROTECTED]

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: Cloning a table with different column names

2007-02-05 Thread Rolando Edwards
Here is something convoluted and sick ...

run 'mysqldump --no-data database table-name' and redirect to a text file.
change the table name and column names in the text file as desired (using perl)
run mysql client redirect input from the text file

Something with more dignity (and no perl)

create table tbl-new like tbl-old;
alter table tbl-new add  column column-2 definition of column-1 after 
column-1;
alter table tbl-new drop column column-1;

Give a try (the latter one, of course)

- Original Message -
From: Tim Johnson [EMAIL PROTECTED]
To: MySQL General Mailing List mysql@lists.mysql.com
Sent: Tuesday, February 6, 2007 7:15:12 AM (GMT-0500) US/Eastern
Subject: Cloning a table with different column names

Hello:

I have a need to create two tables from imported data.
The only difference between the tables is the column names.

The data will be the same.

Can anyone propose a mysql method to create a new table
from an existing table with new column names?

thanks
tim
-- 
Tim Johnson [EMAIL PROTECTED]

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: Cloning a table with different column names

2007-02-05 Thread Tim Johnson
On Monday 05 February 2007 10:07 pm, Rolando Edwards wrote:
  Hi Roland:
 Here is something convoluted and sick ...
   grin convoluted and sick can work. I actually had something
   equally convoluted and sick in mind, but was fishing
   for a second opinion

 run 'mysqldump --no-data database table-name' and redirect to a text
 file. change the table name and column names in the text file as desired
 (using perl) run mysql client redirect input from the text file

 Something with more dignity (and no perl)

 Perl = no dignity? My biz partner likes perl

 create table tbl-new like tbl-old;
 alter table tbl-new add  column column-2 definition of column-1 after
 column-1; alter table tbl-new drop column column-1;
  
  Wham! I like LIKE!
   thanks
   tim

 Give a try (the latter one, of course)

 - Original Message -
 From: Tim Johnson [EMAIL PROTECTED]
 To: MySQL General Mailing List mysql@lists.mysql.com
 Sent: Tuesday, February 6, 2007 7:15:12 AM (GMT-0500) US/Eastern
 Subject: Cloning a table with different column names

 Hello:

 I have a need to create two tables from imported data.
 The only difference between the tables is the column names.

 The data will be the same.

 Can anyone propose a mysql method to create a new table
 from an existing table with new column names?

 thanks
 tim
 --
 Tim Johnson [EMAIL PROTECTED]

-- 
Tim Johnson [EMAIL PROTECTED]

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]