Some SQL statements relating to certain MySQL features produce
errors when used with NDB tables,
as described in the following list:
Temporary tables. Temporary tables are not supported. Trying either to create a temporary table that uses the
NDBstorage engine or to alter an existing temporary table to useNDBfails with the error Table storage engine 'ndbcluster' does not support the create option 'TEMPORARY'.Indexes and keys in NDB tables. Keys and indexes on NDB Cluster tables are subject to the following limitations:
Column width. Attempting to create an index on an
NDBtable column whose width is greater than 3072 bytes is rejected withER_TOO_LONG_KEY: Specified key was too long; max key length is 3072 bytes.Attempting to create an index on an
NDBtable column whose width is greater than 3056 bytes succeeds with a warning. In such cases, statistical information is not generated, which means a nonoptimal execution plan may be selected. For this reason, you should consider making the index length shorter than 3056 bytes if possible.TEXT and BLOB columns. You cannot create indexes on
NDBtable columns that use any of theTEXTorBLOBdata types.FULLTEXT indexes. The
NDBstorage engine does not supportFULLTEXTindexes, which are possible forMyISAMandInnoDBtables only.However, you can create indexes on
VARCHARcolumns ofNDBtables.USING HASH keys and NULL. Using nullable columns in unique keys and primary keys means that queries using these columns are handled as full table scans. To work around this issue, make the column
NOT NULL, or re-create the index without theUSING HASHoption.Prefixes. There are no prefix indexes; only entire columns can be indexed. (The size of an
NDBcolumn index is always the same as the width of the column in bytes, up to and including 3072 bytes, as described earlier in this section. Also see Section 2.7.6, “Unsupported or Missing Features in NDB Cluster”, for additional information.)BIT columns. A
BITcolumn cannot be a primary key, unique key, or index, nor can it be part of a composite primary key, unique key, or index.AUTO_INCREMENT columns. Like other MySQL storage engines, the
NDBstorage engine can handle a maximum of oneAUTO_INCREMENTcolumn per table, and this column must be indexed. However, in the case of an NDB table with no explicit primary key, anAUTO_INCREMENTcolumn is automatically defined and used as a “hidden” primary key. For this reason, you cannot create anNDBtable having anAUTO_INCREMENTcolumn and no explicit primary key.The following
CREATE TABLEstatements do not work, as shown here:# No index on AUTO_INCREMENT column; table has no primary key # Raises ER_WRONG_AUTO_KEY mysql> CREATE TABLE n ( -> a INT, -> b INT AUTO_INCREMENT -> ) -> ENGINE=NDB; ERROR 1075 (42000): Incorrect table definition; there can be only one auto column and it must be defined as a key # Index on AUTO_INCREMENT column; table has no primary key # Raises NDB error 4335 mysql> CREATE TABLE n ( -> a INT, -> b INT AUTO_INCREMENT, -> KEY k (b) -> ) -> ENGINE=NDB; ERROR 1296 (HY000): Got error 4335 'Only one autoincrement column allowed per table. Having a table without primary key uses an autoincr' from NDBCLUSTERThe following statement creates a table with a primary key, an
AUTO_INCREMENTcolumn, and an index on this column, and succeeds:# Index on AUTO_INCREMENT column; table has a primary key mysql> CREATE TABLE n ( -> a INT PRIMARY KEY, -> b INT AUTO_INCREMENT, -> KEY k (b) -> ) -> ENGINE=NDB; Query OK, 0 rows affected (0.38 sec)
Restrictions on foreign keys. Support for foreign key constraints in NDB 8.0 is comparable to that provided by
InnoDB, subject to the following restrictions:Every column referenced as a foreign key requires an explicit unique key, if it is not the table's primary key.
ON UPDATE CASCADEis not supported when the reference is to the parent table's primary key.This is because an update of a primary key is implemented as a delete of the old row (containing the old primary key) plus an insert of the new row (with a new primary key). This is not visible to the
NDBkernel, which views these two rows as being the same, and thus has no way of knowing that this update should be cascaded.ON DELETE CASCADEis also not supported where the child table contains one or more columns of any of theTEXTorBLOBtypes. (Bug #89511, Bug #27484882)SET DEFAULTis not supported. (Also not supported byInnoDB.)The
NO ACTIONkeyword is accepted but treated asRESTRICT.NO ACTION, which is a standard SQL keyword, is the default in MySQL 8.0. (Also the same as withInnoDB.)In earlier versions of NDB Cluster, when creating a table with foreign key referencing an index in another table, it sometimes appeared possible to create the foreign key even if the order of the columns in the indexes did not match, due to the fact that an appropriate error was not always returned internally. A partial fix for this issue improved the error used internally to work in most cases; however, it remains possible for this situation to occur in the event that the parent index is a unique index. (Bug #18094360)
For more information, see FOREIGN KEY Constraints, and FOREIGN KEY Constraints.
NDB Cluster and geometry data types. Geometry data types (
WKTandWKB) are supported forNDBtables. However, spatial indexes are not supported.Character sets and binary log files. Currently, the
ndb_apply_statusandndb_binlog_indextables are created using thelatin1(ASCII) character set. Because names of binary logs are recorded in this table, binary log files named using non-Latin characters are not referenced correctly in these tables. This is a known issue, which we are working to fix. (Bug #50226)To work around this problem, use only Latin-1 characters when naming binary log files or setting any the
--basedir,--log-bin, or--log-bin-indexoptions.Creating NDB tables with user-defined partitioning. Support for user-defined partitioning in NDB Cluster is restricted to [
LINEAR]KEYpartitioning. Using any other partitioning type withENGINE=NDBorENGINE=NDBCLUSTERin aCREATE TABLEstatement results in an error.It is possible to override this restriction, but doing so is not supported for use in production settings. For details, see User-defined partitioning and the NDB storage engine (NDB Cluster).
Default partitioning scheme. All NDB Cluster tables are by default partitioned by
KEYusing the table's primary key as the partitioning key. If no primary key is explicitly set for the table, the “hidden” primary key automatically created by theNDBstorage engine is used instead. For additional discussion of these and related issues, see KEY Partitioning.CREATE TABLEandALTER TABLEstatements that would cause a user-partitionedNDBCLUSTERtable not to meet either or both of the following two requirements are not permitted, and fail with an error:The table must have an explicit primary key.
All columns listed in the table's partitioning expression must be part of the primary key.
Exception. If a user-partitioned
NDBCLUSTERtable is created using an empty column-list (that is, usingPARTITION BY [LINEAR] KEY()), then no explicit primary key is required.Maximum number of partitions for NDBCLUSTER tables. The maximum number of partitions that can defined for a
NDBCLUSTERtable when employing user-defined partitioning is 8 per node group. (See Section 2.2, “NDB Cluster Nodes, Node Groups, Fragment Replicas, and Partitions”, for more information about NDB Cluster node groups.DROP PARTITION not supported. It is not possible to drop partitions from
NDBtables usingALTER TABLE ... DROP PARTITION. The other partitioning extensions toALTER TABLE—ADD PARTITION,REORGANIZE PARTITION, andCOALESCE PARTITION—are supported for NDB tables, but use copying and so are not optimized. See Management of RANGE and LIST Partitions and ALTER TABLE Statement.Partition selection. Partition selection is not supported for
NDBtables. See Partition Selection, for more information.JSON data type. The MySQL
JSONdata type is supported forNDBtables in the mysqld supplied with NDB 8.0.An
NDBtable can have a maximum of 3JSONcolumns.The NDB API has no special provision for working with
JSONdata, which it views simply asBLOBdata. Handling data asJSONmust be performed by the application.DEFAULT value expressions. Explicit default value expressions (as implemented in MySQL 8.0.34 and later) for
NDBtable column definitions are not supported. This means that, for example, the followingCREATE TABLEstatement is rejected with an error:mysql> CREATE TABLE t ( -> id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, -> cf FLOAT DEFAULT (RAND() * 10) -> ) ENGINE=NDBCLUSTER; ERROR 3774 (HY000): 'Specified storage engine' is not supported for default value expressions.NDB Cluster does support literal default column values, as shown here:
mysql> CREATE TABLE t3 ( -> id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, -> ci INT DEFAULT 0, -> cv VARCHAR(20) DEFAULT '' -> ) ENGINE=NDBCLUSTER; Query OK, 0 rows affected (0.17 sec)For more information, see Data Type Default Values.