MySQL 8.0表空間新特性簡單實驗
建立表空間(有沒有發現和oracle命令很像):
mysql> CREATE TABLESPACE `ts1` ADD DATAFILE 'ts1.ibd' Engine=InnoDB;
Query OK, 0 rows affected (0.35 sec)
mysql> select * from information_schema.innodb_tablespaces where name='ts1';
+-------+------+-------+------------+-----------+---------------+------------+---------------+-----------+----------------+----------------+---------------+
| SPACE | NAME | FLAG | ROW_FORMAT | PAGE_SIZE | ZIP_PAGE_SIZE | SPACE_TYPE | FS_BLOCK_SIZE | FILE_SIZE | ALLOCATED_SIZE | SERVER_VERSION | SPACE_VERSION |
+-------+------+-------+------------+-----------+---------------+------------+---------------+-----------+----------------+----------------+---------------+
| 7 | ts1 | 18432 | Any | 16384 | 0 | General | 4096 | 114688 | 65536 | 8.0.11 | 1 |
+-------+------+-------+------------+-----------+---------------+------------+---------------+-----------+----------------+----------------+---------------+
1 row in set (0.00 sec)
建立表時可以指定表空間:
mysql> CREATE TABLE t1 (c1 INT PRIMARY KEY) TABLESPACE ts1 Engine=InnoDB;
Query OK, 0 rows affected (0.18 sec)
刪除表:
mysql> DROP TABLE t1;
Query OK, 0 rows affected (0.07 sec)
但表空間檔案還在:
[root@test data]# ll -h ts1.ibd
-rw-r----- 1 mysql mysql 112K Apr 27 16:15 ts1.ibd
需要
mysql> drop tablespace ts1;
Query OK, 0 rows affected (0.11 sec)
root@test data]# ll -h ts1.ibd
ls: cannot access ts1.ibd: No such file or directory
mysql> CREATE TABLESPACE dsf add datafile 'dsf.ibd' Engine=InnoDB;
Query OK, 0 rows affected (0.17 sec)
表空間改名:
mysql> alter tablespace dsf rename to liuyb;
Query OK, 0 rows affected (0.09 sec)
mysql> select * from information_schema.innodb_tablespaces where name='dsf';
Empty set (0.00 sec)
mysql> select * from information_schema.innodb_tablespaces where name='liuyb';
+-------+-------+-------+------------+-----------+---------------+------------+---------------+-----------+----------------+----------------+---------------+
| SPACE | NAME | FLAG | ROW_FORMAT | PAGE_SIZE | ZIP_PAGE_SIZE | SPACE_TYPE | FS_BLOCK_SIZE | FILE_SIZE | ALLOCATED_SIZE | SERVER_VERSION | SPACE_VERSION |
+-------+-------+-------+------------+-----------+---------------+------------+---------------+-----------+----------------+----------------+---------------+
| 8 | liuyb | 18432 | Any | 16384 | 0 | General | 4096 | 114688 | 65536 | 8.0.11 | 1 |
+-------+-------+-------+------------+-----------+---------------+------------+---------------+-----------+----------------+----------------+---------------+
1 row in set (0.00 sec)
mysql> CREATE TABLESPACE `ts1` ADD DATAFILE 'ts1.ibd' Engine=InnoDB;
Query OK, 0 rows affected (0.35 sec)
mysql> select * from information_schema.innodb_tablespaces where name='ts1';
+-------+------+-------+------------+-----------+---------------+------------+---------------+-----------+----------------+----------------+---------------+
| SPACE | NAME | FLAG | ROW_FORMAT | PAGE_SIZE | ZIP_PAGE_SIZE | SPACE_TYPE | FS_BLOCK_SIZE | FILE_SIZE | ALLOCATED_SIZE | SERVER_VERSION | SPACE_VERSION |
+-------+------+-------+------------+-----------+---------------+------------+---------------+-----------+----------------+----------------+---------------+
| 7 | ts1 | 18432 | Any | 16384 | 0 | General | 4096 | 114688 | 65536 | 8.0.11 | 1 |
+-------+------+-------+------------+-----------+---------------+------------+---------------+-----------+----------------+----------------+---------------+
1 row in set (0.00 sec)
建立表時可以指定表空間:
mysql> CREATE TABLE t1 (c1 INT PRIMARY KEY) TABLESPACE ts1 Engine=InnoDB;
Query OK, 0 rows affected (0.18 sec)
刪除表:
mysql> DROP TABLE t1;
Query OK, 0 rows affected (0.07 sec)
但表空間檔案還在:
[root@test data]# ll -h ts1.ibd
-rw-r----- 1 mysql mysql 112K Apr 27 16:15 ts1.ibd
需要
mysql> drop tablespace ts1;
Query OK, 0 rows affected (0.11 sec)
root@test data]# ll -h ts1.ibd
ls: cannot access ts1.ibd: No such file or directory
mysql> CREATE TABLESPACE dsf add datafile 'dsf.ibd' Engine=InnoDB;
Query OK, 0 rows affected (0.17 sec)
表空間改名:
mysql> alter tablespace dsf rename to liuyb;
Query OK, 0 rows affected (0.09 sec)
mysql> select * from information_schema.innodb_tablespaces where name='dsf';
Empty set (0.00 sec)
mysql> select * from information_schema.innodb_tablespaces where name='liuyb';
+-------+-------+-------+------------+-----------+---------------+------------+---------------+-----------+----------------+----------------+---------------+
| SPACE | NAME | FLAG | ROW_FORMAT | PAGE_SIZE | ZIP_PAGE_SIZE | SPACE_TYPE | FS_BLOCK_SIZE | FILE_SIZE | ALLOCATED_SIZE | SERVER_VERSION | SPACE_VERSION |
+-------+-------+-------+------------+-----------+---------------+------------+---------------+-----------+----------------+----------------+---------------+
| 8 | liuyb | 18432 | Any | 16384 | 0 | General | 4096 | 114688 | 65536 | 8.0.11 | 1 |
+-------+-------+-------+------------+-----------+---------------+------------+---------------+-----------+----------------+----------------+---------------+
1 row in set (0.00 sec)
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/15498/viewspace-2154462/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- MySQL8.0 · 引擎特性 · 關於undo表空間的一些新變化MySql
- MySQL 8.0 新特性MySql
- MySQL 5.7新特性之線上收縮undo表空間MySql
- MySQL8.0新特性-臨時表的改善MySql
- MySQL 8.0.2 新特性 UNDO表空間管理的靈活性提升MySql
- MySQL 5.7新支援--通用表空間實戰MySql
- MySQL 8.0新特性概覽MySql
- MySQL 5.7 新特性 共享臨時表空間及臨時表改進MySql
- MySQL傳輸表空間的簡單使用方法MySql
- MySQL8.0-新特性彙總MySql
- MySQL8.0-新特性-DescendingIndexMySqlIndex
- MySQL 8.0 新特性梳理彙總MySql
- MySQL·8.0新特性·InvisibleIndexMySqlIndex
- MySQL 8.0新特性更新介紹MySql
- 10G 新特性系列: SYSAUX 表空間UX
- Oracle 18c新特性詳解 - 表和表空間相關的新特性Oracle
- MySQL 遷移表空間,備份單表MySql
- MySQL8.0 新特性 top10MySql
- Mysql8.0部分新特性MySql
- mysql8.0新特性--隱藏索引MySql索引
- 10g新特性——表空間重新命名
- 【Oracle 恢復表空間】 實驗Oracle
- Mysql表空間MySql
- oracle表空間管理(簡單記錄)Oracle
- 使用RMAN簡單遷移表空間
- 查詢表空間已使用空間和空閒空間的簡單檢視
- 【11g新特性】Oracle 加密表空間-可下載Oracle加密
- MySQL 8.0新特性-倒敘索引 desc indexMySql索引Index
- MySQL8.0新特性-CTE語法支援MySql
- MySQL·8.0新特性·Newdatadictionary嚐鮮篇MySql
- MySQL8.0 新特性:Partial Update of LOB ColumnMySql
- 表空間TSPITR恢復-實驗
- MySQL 8.0 新增特性MySql
- Oracle10g新特性——利用RMAN遷移表空間Oracle
- Oracle Database 10g新特性-改善的表空間管理OracleDatabase
- MySQL 8.0 18個管理相關的新特性MySql
- MySQL InnoDB 共享表空間和獨立表空間MySql
- MySQL InnoDB 共享表空間和獨立表空間MySql