List:MySQL and .NET« Previous MessageNext Message »
From:Jordan Sparks Date:October 13 2004 6:32pm
Subject:RE: Copy table
View as plain text  
SHOW CREATE TABLE ...

To copy an entire db, I do:
DROP DATABASE IF EXISTS...
CREATE DATABASE ...
SHOW TABLES...
for(int i=0;i<tableNames.Length;i++){
	SHOW CREATE TABLE ...
	ExecuteNonQuery on the result (this creates the table)
	INSERT INTO ... SELECT * FROM ...
}

That's just the skeleton, it does take a little bit of work to create
the function, but it's not bad.  Warning.  SHOW CREATE TABLE is broken
in version 0.76.

Jordan Sparks
  

-----Original Message-----
From: Jorge Bastos [mailto:mysql.jorge@stripped] 
Sent: Wednesday, October 13, 2004 11:06 AM
To: dotnet@stripped
Subject: Copy table


DecimalHi again,

How can i copy a table and it's all structure?
I know one way but not good, like,
CREATE TABLE a SELECT * FROM b
But it won't copy the key's from the table,

Is there another way?

Jorge

Thread
Copy tableJorge Bastos13 Oct
  • RE: Copy tableJordan Sparks13 Oct