show variables like %innodb_file_per_table% ;+..."/>
溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

Enable or Disable file per table

發(fā)布時(shí)間:2020-10-05 10:01:47 來(lái)源:網(wǎng)絡(luò) 閱讀:489 作者:wx584f813adcf41 欄目:MySQL數(shù)據(jù)庫(kù)

MySQL 版本: 5.7.18


1 首先看一下Disable情況下,table 的tablespace存放位置。


mysql> show variables like '%innodb_file_per_table%';
+-----------------------+-------+
| Variable_name         | Value |
+-----------------------+-------+
| innodb_file_per_table | ON    |
+-----------------------+-------+
1 row in set (0.00 sec)

mysql> set global innodb_file_per_table=0;
Query OK, 0 rows affected (0.00 sec)

mysql> show variables like '%innodb_file_per_table%';
+-----------------------+-------+
| Variable_name         | Value |
+-----------------------+-------+
| innodb_file_per_table | OFF   |
+-----------------------+-------+
1 row in set (0.00 sec)


mysql> create table Train.t1 as select * from mysql.user;


ls -l
total 184
-rw-r-----. 1 mysql mysql     65 Jun 13 17:30 db.opt
-rw-r-----. 1 mysql mysql  10816 Jun 14 18:40 t1.frm
-rw-r-----. 1 mysql mysql  17702 Jun 13 17:31 tables.frm
-rw-r-----. 1 mysql mysql 147456 Jun 13 17:31 tables.ibd

note: 只有t1.frm文件,沒(méi)有數(shù)據(jù)文件。


2 再來(lái)我們看一下Enable情況下,我們移動(dòng)一下表。


mysql> show variables like '%innodb_file_per_table%';
+-----------------------+-------+
| Variable_name         | Value |
+-----------------------+-------+
| innodb_file_per_table | OFF   |
+-----------------------+-------+
1 row in set (0.00 sec)

mysql> set global innodb_file_per_table=1;
Query OK, 0 rows affected (0.00 sec)

mysql> show variables like '%innodb_file_per_table%';
+-----------------------+-------+
| Variable_name         | Value |
+-----------------------+-------+
| innodb_file_per_table | ON    |
+-----------------------+-------+
1 row in set (0.00 sec)

mysql> alter table Train.t1 engine=innodb;
Query OK, 0 rows affected (0.18 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> exit
Bye
ls -l
total 280
-rw-r-----. 1 mysql mysql     65 Jun 13 17:30 db.opt
-rw-r-----. 1 mysql mysql  10816 Jun 14 19:21 t1.frm
-rw-r-----. 1 mysql mysql  98304 Jun 14 19:21 t1.ibd
-rw-r-----. 1 mysql mysql  17702 Jun 13 17:31 tables.frm
-rw-r-----. 1 mysql mysql 147456 Jun 13 17:31 tables.ibd

note: innodb_file_per_table=1;
說(shuō)明: innodb_file_per_table=1 情況下移動(dòng)表 alter table Train.t1 engine=innodb
data 目錄下多了 t1.ibd 文件。


向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI