content_image/667095.jpg content_image/667109.jpg
<img src='content_image/667095.jpg'>

This example demonstrates creating a general tablespace and adding a compressed table. The example assumes a default innodb_page_size  of 16KB. The FILE_BLOCK_SIZE  of 8192 requires that the compressed table have a KEY_BLOCK_SIZE  of 8. 

mysql> CREATE TABLESPACE ‘ts2‘ ADD DATAFILE ’ts2.ibd’ FILE_BLOCK_SIZE = 8192 Engine=InnoDB; mysql> CREATE TABLE t4 (c1 INT PRIMARY KEY) TABLESPACE ts2 ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8; 

If you do not specify FILE_BLOCK_SIZE  when creating a general tablespace, FILE_BLOCK_SIZE defaults to innodb_page_size . When FILE_BLOCK_SIZE  is equal to innodb_page_size , the tablespace may only contain tables with an uncompressed row format ( COMPACT , REDUNDANT , and DYNAMIC  row formats). 

## Moving Tables Between Tablespaces Using ALTER TABLE 

ALTER TABLE  with the TABLESPACE  option can be used to move a table to an existing general tablespace, to a new file-per-table tablespace, or to the system tablespace. 

<img src='content_image/667109.jpg'>

## Note 

Support for placing table partitions in shared tablespaces was deprecated in MySQL 5.7.24 and removed MySQL 8.0.13. Shared tablespaces include the InnoDB  system tablespace and general tablespaces. 

To move a table from a file-per-table tablespace or from the system tablespace to a general tablespace, specify the name of the general tablespace. The general tablespace must exist. See ALTER TABLESPACE for more information. 

ALTER TABLE tbl_name TABLESPACE [=] tablespace_name ; 

To move a table from a general tablespace or file-per-table tablespace to the system tablespace, specify innodb_system  as the tablespace name. 

ALTER TABLE tbl_name TABLESPACE [=] innodb_system; 

To move a table from the system tablespace or a general tablespace to a file-per-table tablespace, specify innodb_file_per_table  as the tablespace name. 

