Hi,

----- Original Message -----
From: "Eternal Designs, Inc"
Sent: Saturday, August 30, 2003 9:46 PM
Subject: Re: Newbie Table question


> To copy table A to table B(non-existent) use this command:
>
> CREATE TABLE B SELECT * FROM A;
>
> Note. If your two tables are from different databases the syntax is
> still the same. For instance if table A is in database Da and table B
is
> in database Db then use the MySQL command:
>
> CREATE TABLE Db.B SELECT * FROM Da.A;

Note that this WILL NOT create B with the indexes that A has. So it's
not an exact copy of the structure; just the data. If you want the
indexes from A, you have to specify them in CREATE TABLE:

CREATE TABLE b (
    PRIMARY KEY (pri_key_from_a),
    KEY (other_key_col_from_a)
    -- etc. for any other keys from a
) SELECT * FROM a;



> Peter K Aganyo
>
>
> Tim Winters wrote:
>
> >Hi,
> >
> >How do you copy a table in mySQL.
> >
> >I know I can do it in phpMyAdmin but I want the actual syntax.
> >
> >
> >Thanks!!
> >
> >
> >Tim Winters
> >Creative Development Manager
> >Sampling Technologies Incorporated
> >
> >1600 Bedford Highway, Suite 212
> >Bedford, Nova Scotia
> >B4A 1E8
> >www.samplingtechnologies.com
> >[EMAIL PROTECTED]
> >[EMAIL PROTECTED]
> >Office: 902 450 5500
> >Cell: 902 430 8498
> >Fax:: 902 484 7115
> >
> >
>
> --
> Peter K. Aganyo
> Eternal Designs Inc.,
> +1(617)344-8023 (fax & voicemail)


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

Reply via email to