MySQL Forums
Forum List  »  InnoDB

Re: change innoDB Data DIrectory after creating table?
Posted by: Rick James
Date: January 07, 2015 04:44PM

Which ENGINE is the table? Did you verify that "DATA DIRECTORY=..." works for that engine? Is that a valid option on ALTER TABLE, which is where you need it?

It _may_ be possible to do the following:
1. Set up two databases; lets call them SSD and HDD, reflecting where they reside.
2. Let's say that datadir is on the SSD drive.
3. (one-time effort) Build HDD on the hdd and make a symbolic link (Junction on Windows). This is probably best done with mysqld turned off.
4. When you are ready to move SSD.data_2104 to the hdd, do
RENAME TABLE SSD.data_2104 TO HDD.data_2104;
(I am not sure that RENAME will discover that mv fails because of the cross-device situation and that it will switch to a copy and delete; let's hope it is smart.)

TEST! Test what I suggest on a trivial table before depending on it in production.

BEWARE! ALTER TABLE used to be dumb when it comes to devices. It would blindly build a copy of the table in datadir (or tmpdir?) then do a mv to put it in the right database. First of all, the mv could fail. Secondly, it might "forget" about "DATA DIRECTORY=" that you used to have. So suddenly the table is on the 'wrong' device.

So, TEST that issue:
ALTER TABLE HDD.test ADD COLUMN dummy INT;
Did it stay on the hdd?

This table sounds like something that could/should be PARTITIONed?? If you need to move PARTITIONs, that will involve EXPORT TABLESPACE, etc.

http://bugs.mysql.com/bug.php?id=30459
says:
Quote

Using the DATA DIRECTORY and INDEX DIRECTORY options for partitions
with CREATE TABLE or ALTER TABLE statements appeared to work on Windows,
although they are not supported by MySQL on Windows systems, and
subsequent attempts to use the tables referenced caused errors. Now
these options are disabled on Windows, and attempting to use them
generates a warning.

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: change innoDB Data DIrectory after creating table?
1146
January 07, 2015 04:44PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.