"Xiaobo Chen" <[EMAIL PROTECTED]> wrote on 01/16/2006 03:33:36 PM:

> Hi, all
> 
> How should I copy a table of a database?
> 
> Thanks in advance.
> 
> Xiaobo
> -- 
> Faculty of Computer Science
> Dalhousie University
> Halifax, Nova Scotia
> Canada
> 

Do you want the data or the structure too?

Just the data:

CREATE TABLE newtable SELECT * from oldtable;

Data and the original structure (no foreign keys):

CREATE TABLE newtable LIKE oldtable;
INSERT newtable SELECT * FROM oldtable;

Both forms of CREATE TABLE documented here: 
http://dev.mysql.com/doc/refman/4.1/en/create-table.html

Shawn Green
Database Administrator
Unimin Corporation - Spruce Pine

Reply via email to