ALTER [UNDO] TABLESPACEtablespace_name
NDB only: {ADD | DROP} DATAFILE 'file_name
' [INITIAL_SIZE [=] size] [WAIT] InnoDB and NDB: [RENAME TOtablespace_name
] InnoDB only: [AUTOEXTEND_SIZE [=] 'value
'] [SET {ACTIVE | INACTIVE}] [ENCRYPTION [=] {'Y' | 'N'}] InnoDB and NDB: [ENGINE [=]engine_name
] Reserved for future use: [ENGINE_ATTRIBUTE [=] 'string
']
This statement is used with 此语句用于NDB
and InnoDB
tablespaces. NDB
和InnoDB
表空间。It can be used to add a new data file to, or to drop a data file from an 它可用于向NDB
tablespace. NDB
表空间添加新数据文件,或从NDB
表空间中删除数据文件。It can also be used to rename an NDB Cluster Disk Data tablespace, rename an 它还可用于重命名NDB群集磁盘数据表空间、重命名InnoDB
general tablespace, encrypt an InnoDB
general tablespace, or mark an InnoDB
undo tablespace as active or inactive.InnoDB
通用表空间、加密InnoDB
通用表空间或将InnoDB
撤销表空间标记为活动或非活动。
The MySQL 8.0.14中引入的UNDO
keyword, introduced in MySQL 8.0.14, is used with the SET {ACTIVE | INACTIVE}
clause to mark an InnoDB
undo tablespace as active or inactive. UNDO
关键字与SET{ACTIVE | INACTIVE}
子句一起使用,将InnoDB
撤销表空间标记为激活或失活。For more information, see Section 15.6.3.4, “Undo Tablespaces”.有关更多信息,请参阅第15.6.3.4节,“撤消表空间”。
The ADD DATAFILE
variant enables you to specify an initial size for an NDB
Disk Data tablespace using an INITIAL_SIZE
clause, where size
is measured in bytes; the default value is 134217728 (128 MB). ADD DATAFILE
变量使您能够使用INITIAL_SIZE
子句指定NDB磁盘数据表空间的初始大小,其中size
以字节为单位;默认值为134217728(128 MB)。You may optionally follow 您可以选择在size
with a one-letter abbreviation for an order of magnitude, similar to those used in my.cnf
. size
后面加一个一个字母的缩写,表示一个数量级,类似于my.cnf
中使用的缩写。Generally, this is one of the letters 通常,这是字母M
(megabytes) or G
(gigabytes).M
(兆字节)或G
(千兆字节)中的一个。
On 32-bit systems, the maximum supported value for 在32位系统上,INITIAL_SIZE
is 4294967296 (4 GB). INITIAL_SIZE
的最大支持值为4294967296(4 GB)。(Bug #29186)
INITIAL_SIZE
is rounded, explicitly, as for CREATE TABLESPACE
.INITIAL_SIZE
显式地四舍五入,就像CREATE TABLESPACE
一样。
Once a data file has been created, its size cannot be changed; however, you can add more data files to an NDB tablespace using additional 创建数据文件后,其大小不能更改;但是,您可以使用额外的ALTER TABLESPACE ... ADD DATAFILE
statements.ALTER TABLESPACE ... ADD DATAFILE
语句向NDB表空间添加更多数据文件。
When 当ALTER TABLESPACE ... ADD DATAFILE
is used with ENGINE = NDB
, a data file is created on each Cluster data node, but only one row is generated in the INFORMATION_SCHEMA.FILES
table. ALTER TABLESPACE ... ADD DATAFILE
与ENGINE = NDB
一起使用,在每个集群数据节点上创建一个数据文件,但在INFORMATION_SCHEMA.FILES
表中只生成一行。See the description of this table, as well as Section 23.5.10.1, “NDB Cluster Disk Data Objects”, for more information. 有关更多信息,请参阅此表的说明以及第23.5.10.1节,“NDB群集磁盘数据对象”。ADD DATAFILE
is not supported with InnoDB
tablespaces.InnoDB
表空间不支持添加数据文件。
Using 将DROP DATAFILE
with ALTER TABLESPACE
drops the data file 'file_name
' from an NDB tablespace. DROP DATAFILE
与ALTER TABLESPACE
一起使用会从NDB
表空间中删除数据文件file_name
。You cannot drop a data file from a tablespace which is in use by any table; in other words, the data file must be empty (no extents used). 不能从任何表正在使用的表空间中删除数据文件;换句话说,数据文件必须为空(不使用扩展数据块)。See Section 23.5.10.1, “NDB Cluster Disk Data Objects”. 请参阅第23.5.10.1节,“NDB群集磁盘数据对象”。In addition, any data file to be dropped must previously have been added to the tablespace with 此外,任何要删除的数据文件都必须先前已通过CREATE TABLESPACE
or ALTER TABLESPACE
. CREATE TABLESPACE
或ALTER TABLESPACE
添加到表空间中。DROP DATAFILE
is not supported with InnoDB
tablespaces.InnoDB
表空间不支持DROP DATAFILE
。
WAIT
is parsed but otherwise ignored. WAIT
被解析,但在其他方面被忽略。It is intended for future expansion.这是为了将来的扩展。
The ENGINE
clause, which specifies the storage engine used by the tablespace, is deprecated; expect it to be removed in a future release. ENGINE
子句指定表空间使用的存储引擎,不推荐使用;希望在将来的版本中删除它。The tablespace storage engine is known by the data dictionary, making the 数据字典知道表空间存储引擎,这使得ENGINE
clause obsolete. ENGINE
子句过时。If the storage engine is specified, it must match the tablespace storage engine defined in the data dictionary. 如果指定了存储引擎,则它必须与数据字典中定义的表空间存储引擎匹配。The only values for 与engine_name
compatible with NDB
tablespaces are NDB
and NDBCLUSTER
.NDB
表空间兼容的engine_name
的唯一值是NDB
和NDBCLUSTER
。
RENAME TO
operations are implicitly performed in autocommit
mode, regardless of the autocommit
setting.RENAME TO
操作在autocommit
模式下隐式执行,与autocommit
设置无关。
A 当具有读锁的锁表或刷新表对驻留在表空间中的表生效时,无法执行重命名为操作。RENAME TO
operation cannot be performed while LOCK TABLES
or FLUSH TABLES WITH READ LOCK
is in effect for tables that reside in the tablespace.
Exclusive metadata locks are taken on tables that reside in a general tablespace while the tablespace is renamed, which prevents concurrent DDL. 在重命名常规表空间时,对驻留在该表空间中的表使用独占元数据锁,这会阻止并发DDL。Concurrent DML is supported.支持并发DML。
The 重命名CREATE TABLESPACE
privilege is required to rename an InnoDB
general tablespace.InnoDB
通用表空间需要CREATE TABLESPACE
权限。
The AUTOEXTEND_SIZE
option defines the amount by which InnoDB
extends the size of a tablespace when it becomes full. AUTOEXTEND_SIZE
选项定义InnoDB
在表空间满时扩展表空间大小的量。Introduced in MySQL 8.0.23. 在MySQL 8.0.23中引入。The setting must be a multiple of 4MB. 该设置必须是4MB的倍数。The default setting is 0, which causes the tablespace to be extended according to the implicit default behavior. 默认设置为0,这将根据隐式默认行为扩展表空间。For more information, see Section 15.6.3.9, “Tablespace AUTOEXTEND_SIZE Configuration”.有关更多信息,请参阅第15.6.3.9节,“表空间自动扩展大小配置”。
The ENCRYPTION
clause enables or disables page-level data encryption for an InnoDB
general tablespace or the mysql
system tablespace. ENCRYPTION
子句启用或禁用InnoDB
通用表空间或mysql系统表空间的页面级数据加密。Encryption support for general tablespaces was introduced in MySQL 8.0.13. MySQL 8.0.13中引入了对通用表空间的加密支持。Encryption support for the mysql 8.0.16中引入了对mysql
system tablespace was introduced in MySQL 8.0.16.mysql
系统表空间的加密支持。
A keyring plugin must be installed and configured before encryption can be enabled.在启用加密之前,必须安装并配置密钥环插件。
As of MySQL 8.0.16, if the 从MySQL 8.0.16开始,如果启用了table_encryption_privilege_check
variable is enabled, the TABLE_ENCRYPTION_ADMIN
privilege is required to alter a general tablespace with an ENCRYPTION
clause setting that differs from the default_table_encryption
setting.table_encryption_privilege_check
变量,则需要TABLE_ENCRYPTION_ADMIN
权限来更改具有不同于default_table_encryption
设置的ENCRYPTION
子句设置的常规表空间。
Enabling encryption for a general tablespace fails if any table in the tablespace belongs to a schema defined with 如果表空间中的任何表属于使用DEFAULT ENCRYPTION='N'
. DEFAULT ENCRYPTION='N'
定义的架构,则为常规表空间启用加密将失败。Similarly, disabling encryption fails if any table in the general tablespace belongs to a schema defined with 类似地,如果常规表空间中的任何表属于使用默认DEFAULT ENCRYPTION='Y'
. DEFAULT ENCRYPTION='Y'
定义的模式,则禁用加密将失败。The MySQL 8.0.16中引入了DEFAULT ENCRYPTION
schema option was introduced in MySQL 8.0.16.DEFAULT ENCRYPTION
架构选项。
If an 如果在常规表空间上执行的ALTER TABLESPACE
statement executed on a general tablespace does not include an ENCRYPTION
clause, the tablespace retains its current encryption status, regardless of the default_table_encryption
setting.ALTER TABLESPACE
语句不包含ENCRYPTION
子句,则无论default_table_encryption
设置如何,该表空间都将保留其当前加密状态。
When a general tablespace or the 加密常规表空间或mysql
system tablespace is encrypted, all tables residing in the tablespace are encrypted. mysql
系统表空间时,表空间中的所有表都会加密。Likewise, a table created in an encrypted tablespace is encrypted.同样,在加密表空间中创建的表也是加密的。
The 当更改常规表空间或INPLACE
algorithm is used when altering the ENCRYPTION
attribute of a general tablespace or the mysql
system tablespace. mysql
系统表空间的ENCRYPTION
属性时,将使用INPLACE
算法。The INPLACE
algorithm permits concurrent DML on tables that reside in the tablespace. INPLACE
算法允许对驻留在表空间中的表执行并发DML。Concurrent DDL is blocked.并发DDL被阻止。
For more information, see Section 15.13, “InnoDB Data-at-Rest Encryption”.有关更多信息,请参阅第15.13节,“InnoDB
静态数据加密”。
The ENGINE_ATTRIBUTE
option (available as of MySQL 8.0.21) is used to specify tablespace attributes for primary storage engines. ENGINE_ATTRIBUTE
选项(从MySQL 8.0.21开始提供)用于为主存储引擎指定表空间属性。The option is reserved for future use.该选项保留供将来使用。
Permitted values are a string literal containing a valid 允许的值是包含有效JSON
document or an empty string (''). JSON
文档的字符串文字或空字符串(''
)。Invalid 无效的JSON
is rejected.JSON
会被拒绝。
ALTER TABLESPACE ts1 ENGINE_ATTRIBUTE='{"key
":"value
"}';
ENGINE_ATTRIBUTE
values can be repeated without error. ENGINE_ATTRIBUTE
值可以无错误地重复。In this case, the last specified value is used.在这种情况下,将使用最后指定的值。
服务器不会检查ENGINE_ATTRIBUTE
values are not checked by the server, nor are they cleared when the table's storage engine is changed.ENGINE_ATTRIBUTE
,也不会在更改表的存储引擎时清除这些值。
It is not permitted to alter an individual element of a JSON attribute value. 不允许更改JSON属性值的单个元素。You can only add or replace an attribute.只能添加或替换属性。