Robert L Cochran <cochranb@stripped> wrote on 10/17/2005 07:37:26 AM:
> I think you can just rename the directory that that database lives in.
> If you read the documentation for CREATE DATABASE in dev.mysql.com,
> you'll see they discuss renaming the directory (although it does not
> directly say this can be done to rename the database, but it comes
> really close to that.) Based on the documentation the database name is
> simply a directory name, no more and no less.
> Renaming tables has its own command syntax, you can look it up.
> Bob Cochran
> Octavian Rasnita wrote:
> >Is there a command for renaming a MySQL database?
> >Thank you.
The only way I have done it has been to create an empty database with the
name I want. Then I used RENAME TABLE to "move" all of the tables into the
new database. Sure it takes a lot of RENAME TABLE statements but it works.
If these are InnoDB tables, all I am doing is moving metadata and that is
FAST. For MyISAM or other file-based storage engines, it copies files from
one folder to another. For some file systems, that is also just a metadata
shift and will still be FAST. Others will require a physical move of the
data from one location to another (good thing that those filesystems are
becoming quite rare these days)
I have a 2.1GB database with all InnoDB tables in it that I wanted to
change the name of. It took me longer to write my RENAME TABLE script than
it did to actually move the data.
Unimin Corporation - Spruce Pine