MySQL - ALTER TABLE SPACE Statement



ALTER TABLE SPACE Statement

The Alter TABLE SPACE statement of MySQL helps to perform changes on a table space. Using this statement, we can add, delete a data file.

Syntax

Following is the syntax of the ALTER TABLESPACE statement −

ALTER TABLESPACE tablespace_name {ADD | DROP} DATAFILE 'file_name'

Where, tablespace_name is the name of the existing table space you need to change.

Example

Assume we have created a table space as shown below −

CREATE TABLESPACE sample ENGINE = INNODB;

Following query renames the above created table space −

ALTER TABLESPACE sample RENAME TO demo;

Once you rename the table space if you try to alter it again an error will be generated as −

ALTER TABLESPACE sample RENAME TO test;
ERROR 3510 (HY000): Tablespace sample doesn't exist.
mysql_statements_reference.htm
Advertisements