ALTER [UNDO] TABLESPACEtablespace_nameNDB 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']
该语句用于 NDB 和 InnoDB 表空间。它可以用于向 NDB。它还可用于重命名 NDB 集群磁盘表空间,重命名 InnoDB 通用表空间,加密 InnoDB 通用表空间,或将 InnoDB销表空间标记为活跃或非活跃。This statement is used with NDB and
InnoDB tablespaces. It can be used to add a new
data file to, or to drop a data file from an
NDB tablespace. It can also be used to rename
an NDB Cluster Disk Data tablespace, rename an
InnoDB general tablespace, encrypt an
InnoDB general tablespace, or mark an
InnoDB undo tablespace as active or inactive.
UNDO 关键字与 SET
{ACTIVE | INACTIVE} 子句一起使用,用于将 InnoDB 撤销表空间标记为活动或非活动。欲了解更多信息,请参见 第 17.6.3.4 节,“撤销表空间”。The UNDO keyword is used with the SET
{ACTIVE | INACTIVE} clause to mark an
InnoDB undo tablespace as active or inactive.
For more information, see
Section 17.6.3.4, “Undo Tablespaces”.
ADD DATAFILE 变体允许你使用 INITIAL_SIZE 子句为 NDB 磁盘表空间指定初始大小,其中 size 单位为字节;默认值为 134217728(128 MB)。可选地,你可以在 size 后添加一个表示数量级的单字母缩写,类似于 my.cnf 中使用的缩写。通常,这个字母是 M(兆字节)或 G(千兆字节)之一。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). You may optionally follow
size with a one-letter abbreviation for
an order of magnitude, similar to those used in
my.cnf. Generally, this is one of the letters
M (megabytes) or G
(gigabytes).
在 32 位系统上,INITIAL_SIZE 支持的最大值为 4294967296(4 GB)。(Bug #29186)On 32-bit systems, the maximum supported value for
INITIAL_SIZE is 4294967296 (4 GB). (Bug #29186)
INITIAL_SIZE 的取整方式与 CREATE TABLESPACE 相同,属于显式取整。INITIAL_SIZE is rounded, explicitly, as for
CREATE TABLESPACE.
一旦创建了数据文件,其大小无法更改;但是,你可以使用额外的 NDB 语句向 ALTER TABLESPACE ... ADD
DATAFILE 表空间添加更多数据文件。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.
当对 ENGINE = NDB 使用 ALTER TABLESPACE ... ADD DATAFILE 时,每个集群数据节点都会创建一个数据文件,但在信息模式 FILES 表中只会生成一行。有关更多信息,请参见该表的描述,以及 第 25.6.11.1 节,“NDB 集群磁盘数据对象”。ADD DATAFILE 不支持 InnoDB 表空间。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. See
the description of this table, as well as
Section 25.6.11.1, “NDB Cluster Disk Data Objects”, for more
information. ADD DATAFILE is not supported with
InnoDB tablespaces.
使用 DROP DATAFILE 与 ALTER TABLESPACE 可以从 NDB 表空间中删除数据文件 'file_name'。你不能从正在被任意表使用的表空间中删除数据文件;换句话说,数据文件必须为空(未使用任何区块)。参见 第 25.6.11.1 节,“NDB 集群磁盘数据对象”。此外,任何要删除的数据文件必须先通过 CREATE TABLESPACE 或 ALTER TABLESPACE 添加到表空间中。DROP
DATAFILE 不支持 InnoDB 表空间。Using DROP DATAFILE with
ALTER TABLESPACE drops the data
file 'file_name' from an
NDB tablespace. 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 25.6.11.1, “NDB Cluster Disk Data Objects”. In addition,
any data file to be dropped must previously have been added to the
tablespace with CREATE TABLESPACE
or ALTER TABLESPACE. DROP
DATAFILE is not supported with InnoDB
tablespaces.
WAIT 会被解析,但会被忽略。它是为未来扩展而设置的。WAIT is parsed but otherwise ignored. It is
intended for future expansion.
ENGINE 子句指定表空间使用的存储引擎,但该子句已被弃用,因为表空间的存储引擎已由数据字典识别,使得 ENGINE 子句变得多余。在 MySQL 8.4 中,它仅在以下两种情况下受支持:The ENGINE clause, which specifies the storage
engine used by the tablespace, is deprecated, since the tablespace
storage engine is known by the data dictionary, making the
ENGINE clause obsolete. In MySQL
8.4, it is supported in the following two cases only:
ALTER TABLESPACE
tablespace_nameADD DATAFILE 'file_name' ENGINE={NDB|NDBCLUSTER}ALTER UNDO TABLESPACE
tablespace_nameSET {ACTIVE|INACTIVE} ENGINE=INNODB
您应当预期在未来版本的 MySQL 中,这些语句中的 ENGINE 也将被最终移除。You should expect the eventual removal of
ENGINE from these statements as well, in a
future version of MySQL.
RENAME TO 操作会在自动提交模式下隐式执行,无论 autocommit 的值是什么。RENAME TO operations are implicitly performed
in autocommit mode, regardless of the value of
autocommit.
在 LOCK TABLES 或 RENAME TO 对位于表空间中的表生效时,不能执行 FLUSH TABLES WITH READ
LOCK 操作。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.
在重命名表空间期间,将对位于通用表空间中的表获取排他性的 元数据锁,从而阻止并发 DDL 操作。并发 DML 操作是受支持的。Exclusive metadata locks are taken on tables that reside in a general tablespace while the tablespace is renamed, which prevents concurrent DDL. Concurrent DML is supported.
重命名 InnoDB 通用表空间需要 CREATE TABLESPACE 权限。The CREATE TABLESPACE privilege is
required to rename an InnoDB general
tablespace.
AUTOEXTEND_SIZE 选项定义了当表空间满时,InnoDB 扩展表空间大小的增量。该设置必须为 4MB 的倍数。默认设置为 0,这会使表空间按隐式默认行为扩展。有关更多信息,请参见 第 17.6.3.9 节,“表空间 AUTOEXTEND_SIZE 配置”。The AUTOEXTEND_SIZE option defines the amount
by which InnoDB extends the size of a
tablespace when it becomes full. The setting must be a multiple of
4MB. The default setting is 0, which causes the tablespace to be
extended according to the implicit default behavior. For more
information, see
Section 17.6.3.9, “Tablespace AUTOEXTEND_SIZE Configuration”.
ENCRYPTION 子句用于启用或禁用 InnoDB 通用表空间或 mysql 系统表空间的页级数据加密。The ENCRYPTION clause enables or disables
page-level data encryption for an InnoDB
general tablespace or the mysql system
tablespace.
必须安装并配置钥匙串插件,然后才能启用加密。A keyring plugin must be installed and configured before encryption can be enabled.
如果启用了 table_encryption_privilege_check 变量,则修改通用表空间时,如果 ENCRYPTION 子句设置不同于 default_table_encryption 设置,则需要具有 TABLE_ENCRYPTION_ADMIN 权限。If the
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.
如果表空间中的任何表属于用 DEFAULT
ENCRYPTION='N' 定义的模式,则启用通用表空间加密操作会失败。同样,如果表空间中的任何表属于用 DEFAULT ENCRYPTION='Y' 定义的模式,则禁用加密操作会失败。Enabling encryption for a general tablespace fails if any table in
the tablespace belongs to a schema defined with DEFAULT
ENCRYPTION='N'. Similarly, disabling encryption fails if
any table in the general tablespace belongs to a schema defined
with DEFAULT ENCRYPTION='Y'.
如果在通用表空间上执行的 ALTER TABLESPACE 语句未包含 ENCRYPTION 子句,则表空间将保持其当前的加密状态,而不会受到 default_table_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.
当通用表空间或 mysql 系统表空间被加密时,表空间中的所有表都会被加密。同样,在加密表空间中创建的表也会被加密。When a general tablespace or the mysql system
tablespace is encrypted, all tables residing in the tablespace are
encrypted. Likewise, a table created in an encrypted tablespace is
encrypted.
在修改通用表空间或 mysql 系统表空间的 ENCRYPTION 属性时,会使用 INPLACE 算法。INPLACE 算法允许对表空间中的表进行并发 DML 操作,但并发 DDL 会被阻止。The INPLACE algorithm is used when altering the
ENCRYPTION attribute of a general tablespace or
the mysql system tablespace. The
INPLACE algorithm permits concurrent DML on
tables that reside in the tablespace. Concurrent DDL is blocked.
有关更多信息,请参见第 17.13 节,“InnoDB 静态数据加密”。For more information, see Section 17.13, “InnoDB Data-at-Rest Encryption”.
ENGINE_ATTRIBUTE 选项用于为主存储引擎指定表空间属性。该选项为将来使用保留。The ENGINE_ATTRIBUTE option is used to specify
tablespace attributes for primary storage engines. The option is
reserved for future use.
分配给此选项的值是包含有效 JSON 文档的字符串字面量或空字符串('')。无效的 JSON 会被拒绝。The value assigned to this option is a string literal containing a valid JSON document or an empty string (''). Invalid JSON is rejected.
ALTER TABLESPACE ts1 ENGINE_ATTRIBUTE='{"key":"value"}';
ENGINE_ATTRIBUTE 的值可以重复而不会报错。在这种情况下,将使用最后指定的值。ENGINE_ATTRIBUTE values can be repeated without
error. In this case, the last specified value is used.
ENGINE_ATTRIBUTE 的值不会被服务器检查,也不会在更改表的存储引擎时被清除。ENGINE_ATTRIBUTE values are not checked by the
server, nor are they cleared when the table's storage engine
is changed.
不允许更改 JSON 属性值的单个元素。您只能添加或替换属性。It is not permitted to alter an individual element of a JSON attribute value. You can only add or replace an attribute.