DROP [UNDO] TABLESPACEtablespace_name[ENGINE [=]engine_name]
This statement drops a tablespace that was previously created using 此语句删除以前使用CREATE TABLESPACE. CREATE TABLESPACE创建的表空间。It is supported by the 它由NDB和NDB and InnoDB storage engines.InnoDB存储引擎支持。
The MySQL 8.0.14中引入的UNDO keyword, introduced in MySQL 8.0.14, must be specified to drop an undo tablespace. UNDO关键字必须指定才能删除UNDO表空间。Only undo tablespaces created using 只能删除使用CREATE UNDO TABLESPACE syntax can be dropped. CREATE UNDO TABLESPACE语法创建的撤销表空间。An undo tablespace must be in an 撤消表空间必须处于empty state before it can be dropped. EMPTY状态才能删除。For more information, see Section 15.6.3.4, “Undo Tablespaces”.有关更多信息,请参阅第15.6.3.4节,“撤消表空间”。
ENGINE sets the storage engine that uses the tablespace, where engine_name is the name of the storage engine. ENGINE设置使用表空间的存储引擎,其中engine_name是存储引擎的名称。Currently, the values 目前,支持InnoDB and NDB are supported. InnoDB和NDB值。If not set, the value of 如果未设置,则使用default_storage_engine is used. default_storage_engine的值。If it is not the same as the storage engine used to create the tablespace, the 如果它与用于创建表空间的存储引擎不同,DROP TABLESPACE statement fails.DROP TABLESPACE语句将失败。
is a case-sensitive identifier in MySQL.tablespace_nametablespace_name是MySQL中区分大小写的标识符。
For an 对于InnoDB general tablespace, all tables must be dropped from the tablespace prior to a DROP TABLESPACE operation. InnoDB通用表空间,在执行DROP TABLESPACE操作之前,必须从表空间中删除所有表。If the tablespace is not empty, 如果表空间不是空的,DROP TABLESPACE returns an error.DROP TABLESPACE将返回一个错误。
An 要删除的NDB tablespace to be dropped must not contain any data files; in other words, before you can drop an NDB tablespace, you must first drop each of its data files using ALTER TABLESPACE ... DROP DATAFILE.NDB表空间不能包含任何数据文件;换句话说,在删除NDB表空间之前,必须首先使用ALTER TABLESPACE ... DROP DATAFILE删除其每个数据文件。
A general 删除表空间中的最后一个表时,一般InnoDB tablespace is not deleted automatically when the last table in the tablespace is dropped. InnoDB表空间不会自动删除。The tablespace must be dropped explicitly using 必须使用DROP TABLESPACE .tablespace_nameDROP TABLESPACE 显式删除表空间。tablespace_name
A DROP DATABASE operation can drop tables that belong to a general tablespace but it cannot drop the tablespace, even if the operation drops all tables that belong to the tablespace. DROP DATABASE操作可以删除属于常规表空间的表,但不能删除该表空间,即使该操作删除属于该表空间的所有表。The tablespace must be dropped explicitly using 必须使用DROP TABLESPACE .tablespace_nameDROP TABLESPACE 显式删除表空间。tablespace_name
Similar to the system tablespace, truncating or dropping tables stored in a general tablespace creates free space internally in the general tablespace .ibd data file which can only be used for new 与系统表空间类似,截断或删除存储在常规表空间中的表会在一般表控件.ibd数据文件内部创建可用空间,该文件只能用于新的InnoDB data. InnoDB数据。Space is not released back to the operating system as it is for file-per-table tablespaces.空间不会像每个表的文件表空间那样释放回操作系统。
InnoDB示例This example demonstrates how to drop an 此示例演示如何删除InnoDB general tablespace. InnoDB通用表空间。The general tablespace 通用表空间ts1 is created with a single table. ts1是使用单个表创建的。Before dropping the tablespace, the table must be dropped.在删除表空间之前,必须删除该表。
mysql>CREATE TABLESPACE `ts1` ADD DATAFILE 'ts1.ibd' Engine=InnoDB;mysql>CREATE TABLE t1 (c1 INT PRIMARY KEY) TABLESPACE ts1 Engine=InnoDB;mysql>DROP TABLE t1;mysql>DROP TABLESPACE ts1;
This example demonstrates dropping an undo tablespace. 此示例演示如何删除撤消表空间。An undo tablespace must be in an 撤消表空间必须处于empty state before it can be dropped. empty状态才能删除。For more information, see Section 15.6.3.4, “Undo Tablespaces”.有关更多信息,请参阅第15.6.3.4节,“撤消表空间”。
mysql> DROP UNDO TABLESPACE undo_003;
This example shows how to drop an 此示例演示如何在首次创建表空间后删除具有名为NDB tablespace myts having a data file named mydata-1.dat after first creating the tablespace, and assumes the existence of a log file group named mylg (see Section 13.1.16, “CREATE LOGFILE GROUP Statement”).mydata-1.dat的数据文件的NDB表空间myts,并假设存在名为mylg的日志文件组(请参阅第13.1.16节,“创建日志文件组语句”)。
mysql>CREATE TABLESPACE myts->ADD DATAFILE 'mydata-1.dat'->USE LOGFILE GROUP mylg->ENGINE=NDB;
You must remove all data files from the tablespace using 必须使用ALTER TABLESPACE, as shown here, before it can be dropped:ALTER TABLESPACE从表空间中删除所有数据文件,如下所示,然后才能删除:
mysql>ALTER TABLESPACE myts->DROP DATAFILE 'mydata-1.dat'->ENGINE=NDB;mysql>DROP TABLESPACE myts;