MySQL innodb use exclusive tablespace

Since MySQL version 4.1, InnoDB has provided two alternatives for how tables are stored on disk. You can create a new table and its indexes in the shared system tablespace, physically stored in the ibdata files. Or, you can store a new table and its indexes in a separate tablespace (a .ibd file). The storage layout for each InnoDB table is determined by the configuration parameter innodb_file_per_table at the time the table is created.
In MySQL 5.5 and higher, the configuration parameter innodb_file_per_table is dynamic, and can be set ON or OFF using the SET GLOBAL. Previously, the only way to set this parameter was in the MySQL option file (my.cnf or my.ini), and changing it required shutting down and restarting the server.

The default setting is OFF, so new tables and indexes are created in the system tablespace. Dynamically changing the value of this parameter requires the SUPER privilege and immediately affects the operation of all connections.


example

[root@test mysql]# /service/mysql/bin/mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.5.25-log zhongwc_DB

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> create database innotest;
Query OK, 1 row affected (0.00 sec)

mysql> show create database innotest;
+----------+-------------------------------------------------------------------+
| Database | Create Database                                                   |
+----------+-------------------------------------------------------------------+
| innotest | CREATE DATABASE `innotest` /*!40100 DEFAULT CHARACTER SET utf8 */ |
+----------+-------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> use innotest
Database changed
mysql> create table innoper1 engine = innodb as select * from zwc.employee;
Query OK, 1000000 rows affected (5.99 sec)
Records: 1000000  Duplicates: 0  Warnings: 0

mysql> create table innoper2 engine = innodb as select * from zwc.employee_myisam;
Query OK, 1000000 rows affected (5.04 sec)
Records: 1000000  Duplicates: 0  Warnings: 0

mysql> exit
Bye
[root@test mysql]# pwd
/data/mysql
[root@test mysql]# cd innotest/
[root@test innotest]# ls -lh
total 113M
-rw-rw---- 1 mysql mysql   61 Jan 10 15:17 db.opt
-rw-rw---- 1 mysql mysql 8.5K Jan 10 15:17 innoper1.frm
-rw-rw---- 1 mysql mysql  56M Jan 10 15:18 innoper1.ibd
-rw-rw---- 1 mysql mysql 8.5K Jan 10 15:18 innoper2.frm
-rw-rw---- 1 mysql mysql  56M Jan 10 15:18 innoper2.ibd

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


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值