By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,225 Members | 2,170 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,225 IT Pros & Developers. It's quick & easy.

Copying a table from one schema to another

P: n/a
Is it possible to copy a table from one schema to another schema by just
copying the frm file to the directory for the new schema?

What is the best way to create a new database with all the tables in it
automatically?

I was hoping to have the tables (the frm files) included in a subdirectory
and when required, just create a new schema then copy all the frm files into
it.

Any help greatly appreciated.

Tks
John
Jan 30 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
"zMisc" <yo********@hotmail.com> wrote in message
news:_N*******************@news-server.bigpond.net.au...
Is it possible to copy a table from one schema to another schema by just
copying the frm file to the directory for the new schema?

What is the best way to create a new database with all the tables in it
automatically?

I was hoping to have the tables (the frm files) included in a subdirectory
and when required, just create a new schema then copy all the frm files into it.

Any help greatly appreciated.


I am going to *cautiously* suggest that you can simply create your new,
replicate, database by copying the entire database directory recursively to
a new directory in the mysql "data" directory. You want to replicate
*everything* - not just .frm files and you want to make sure MySQL retains
ownership of the new directory and all it's files.

In linux you can chdir to the mysql data directory and (as root!) issue the
cp (copy) command.
cp -p -R {OriginalDB} {ReplicateDB}

The [-p] switch preserves mysql file ownership and [-R] replicates the
*entire* database directory with all the files it contains.

This works neat as a pin in 4.0x and 4.1x versions of MySQL. I don't *know*
about version 5.0 or about MS Windows.

Thomas Bartkus


Jan 30 '06 #2

P: n/a
"zMisc" <yo********@hotmail.com> wrote in message
news:_N*******************@news-server.bigpond.net.au...
Is it possible to copy a table from one schema to another schema by just
copying the frm file to the directory for the new schema?


I never try to do database operations by manipulating the files at the
filesystem level.

I would do what you describe using mysqldump piped through mysql.

You can make mysqldump output skip the "create database" statement, and then
run the mysql tool with respect to a new, empty database (or any other
existing database). You can also make mysqldump back up selected tables
instead of a whole database. You can also make mysqldump back up table
schema only, without the contents of the tables if that is what you want.

There is enough flexibility to do what you want using proper tools, without
resorting to manipulating the myd and frm files.

Regards,
Bill K.
Jan 30 '06 #3

P: n/a
Hi Bill,

I can only see .frm files - there are no .myd files what are the myd files?

I am using MySQL 5.

Tks
"Bill Karwin" <bi**@karwin.com> wrote in message
news:dr*********@enews1.newsguy.com...
"zMisc" <yo********@hotmail.com> wrote in message
news:_N*******************@news-server.bigpond.net.au...
Is it possible to copy a table from one schema to another schema by just
copying the frm file to the directory for the new schema?


I never try to do database operations by manipulating the files at the
filesystem level.

I would do what you describe using mysqldump piped through mysql.

You can make mysqldump output skip the "create database" statement, and
then run the mysql tool with respect to a new, empty database (or any
other existing database). You can also make mysqldump back up selected
tables instead of a whole database. You can also make mysqldump back up
table schema only, without the contents of the tables if that is what you
want.

There is enough flexibility to do what you want using proper tools,
without resorting to manipulating the myd and frm files.

Regards,
Bill K.

Jan 31 '06 #4

P: n/a
>I can only see .frm files - there are no .myd files what are the myd files?

Files containing MyISAM table data.
I am using MySQL 5.


And probably InnoDB tables, so you won't have .MYD files.

Gordon L. Burditt
Jan 31 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.