# pt-online-schema-change tmp datadir

**URL:** <https://forums.percona.com/t/pt-online-schema-change-tmp-datadir/7062>\
**Category:** Percona Toolkit\
**Created:** [June 16, 2019, 10:22am UTC](https://forums.percona.com/t/pt-online-schema-change-tmp-datadir/7062 "2019-06-16T10:22:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![yurikab](https://avatars.discourse-cdn.com/v4/letter/y/a88e57/32.png) [@yurikab](https://forums.percona.com/u/yurikab)\
**Post date:** [June 16, 2019, 10:22am UTC](https://forums.percona.com/t/pt-online-schema-change-tmp-datadir/7062/1 "2019-06-16T10:22:12Z")

</div>

Hello, is there a way to set DATA DIR for temp table (not changing original table datadir) while changing schema via pt-online-schema change ?  
I haven’t enough free space for temp table.

---

<div class="post-metadata">

**Author:** ![yurikab](https://avatars.discourse-cdn.com/v4/letter/y/a88e57/32.png) [@yurikab](https://forums.percona.com/u/yurikab)\
**Post date:** [June 17, 2019, 1:15am UTC](https://forums.percona.com/t/pt-online-schema-change-tmp-datadir/7062/2 "2019-06-17T01:15:18Z")

</div>

If i’m right only one solution to do it is:

1. use pt-online-schema-change with --data-dir, --no-drop-new-table and --no-swap-tables
2. ALTER TABLE `old_table` DISCARD TABLESPACE;
3. FLUSH TABLES `new_table` FOR EXPORT;
4. move idb,cfg from new\_table to old\_table (mv /tmp/datadir/db/new\_table.ibd /old/datadir/db/old\_table.idb) and chown to mysql user
5. UNLOCK TABLES;
6. ALTER TABLE `old_table` IMPORT TABLESPACE;
7. drop new\_table;

as i’m right ?

---

<div class="post-metadata">

**Author:** ![carlos.salguero](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/carlos.salguero/32/20_2.png) [@carlos.salguero](https://forums.percona.com/u/carlos.salguero)\
**Post date:** [June 18, 2019, 6:47am UTC](https://forums.percona.com/t/pt-online-schema-change-tmp-datadir/7062/3 "2019-06-18T06:47:49Z")

</div>

The steps you mentioned are risky and won’t be “online”  
You could run pt-osc twice using --data-dir. The first run will alter your table with the new structure and the second time will move it again to the original location.

---

<div class="post-metadata">

**Author:** ![yurikab](https://avatars.discourse-cdn.com/v4/letter/y/a88e57/32.png) [@yurikab](https://forums.percona.com/u/yurikab)\
**Post date:** [June 18, 2019, 12:14pm UTC](https://forums.percona.com/t/pt-online-schema-change-tmp-datadir/7062/4 "2019-06-18T12:14:26Z")

</div>

> [@carlos.salguero;54195](#):
>
> The steps you mentioned are risky and won’t be “online”  
> You could run pt-osc twice using --data-dir. The first run will alter your table with the new structure and the second time will move it again to the original location.

Could you help me by step ? =)
