Re: Table copy problem

2002-12-05 Thread Keith C. Ivey
On 5 Dec 2002, at 14:44, Ol h Barnab s wrote:

 SELECT * INTO [temptablename] FROM [sourcetablename] WHERE id is null

 and the SQL server creates a [temptablename] table with no records (or we
 hope that ;) )
 But we can't do this on MySQL server, 'cause MySQL isn't know the
 SELECT...INTO syntax, but in the INSERT...INTO syntax, we must count the
 columns, which we wnat to create. (it's not good for me...)

If I understand you correctly, the query you want is

   CREATE TABLE temptablename SELECT * FROM sourcetablename LIMIT 0;

The only problem is that indexes and some other properties of the
source table (defaults, for example) are not copied over, but I
imagine that happens with your MS SQL statement as well.  If you need
to preserve those things, you'll have to take the output from SHOW
CREATE TABLE sourcetablename, change the table name in the SQL, and
execute the new statement.

--
Keith C. Ivey [EMAIL PROTECTED]
Tobacco Documents Online
http://tobaccodocuments.org
Phone 202-667-6653

-
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: Table copy problem

2002-12-05 Thread Victoria Reznichenko
Oláh,
Thursday, December 05, 2002, 2:44:24 PM, you wrote:

OB I want to copy one table's structure to another (non existing) table, but i
OB didn't find any command or example to do that. Exactly, the situation is the
OB following:
OB A dynamic database structure has tables. We want to copy any of tha tables
OB (while we don't know that table's structure) to another template table,
OB which isn't exist. So, that looks like on MsSQL:

OB SELECT * INTO [temptablename] FROM [sourcetablename] WHERE id is null

OB and the SQL server creates a [temptablename] table with no records (or we
OB hope that ;) )
OB But we can't do this on MySQL server, 'cause MySQL isn't know the
OB SELECT...INTO syntax, but in the INSERT...INTO syntax, we must count the
OB columns, which we wnat to create. (it's not good for me...)

OB Can somebody solve this problem? Or it's willn't work for the next version?
OB (uhh-uhh, thats the worst...)

You can use:
  CREATE TABLE new_table SELECT * FROM old_table LIMIT 0;

but you must create indexes manually.



-- 
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: Table copy problem

2002-12-05 Thread Listen Hinz
Dear Olh,

 SELECT * INTO [temptablename] FROM [sourcetablename] WHERE id is
null

In MySQL, you simply do:

CREATE TABLE temptable SELECT * FROM sourcetable LIMIT 0

That's even simpler, 100% reliable and FAST! :)

HTH!
--
  Stefan Hinz [EMAIL PROTECTED]
  Geschftsfhrer / CEO iConnect GmbH http://iConnect.de
  Heesestr. 6, 12169 Berlin (Germany)
  Tel: +49 30 7970948-0  Fax: +49 30 7970948-3


- Original Message -
From: Olh Barnabs [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, December 05, 2002 1:44 PM
Subject: Table copy problem


 Hello!

 I want to copy one table's structure to another (non existing) table,
but i
 didn't find any command or example to do that. Exactly, the situation
is the
 following:
 A dynamic database structure has tables. We want to copy any of tha
tables
 (while we don't know that table's structure) to another template
table,
 which isn't exist. So, that looks like on MsSQL:

 SELECT * INTO [temptablename] FROM [sourcetablename] WHERE id is
null

 and the SQL server creates a [temptablename] table with no records (or
we
 hope that ;) )
 But we can't do this on MySQL server, 'cause MySQL isn't know the
 SELECT...INTO syntax, but in the INSERT...INTO syntax, we must count
the
 columns, which we wnat to create. (it's not good for me...)

 Can somebody solve this problem? Or it's willn't work for the next
version?
 (uhh-uhh, thats the worst...)

 Thanx,
 Barnabas Olah
 Cegedim Hungary



 -
 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