Documentation Home
MySQL NDB Cluster API Developer Guide
Download this Manual

2.3.37 The Table Class Table::addColumn() Table::aggregate() Table Constructor Table::equal() Table::getColumn() Table::getDefaultNoPartitionsFlag() Table::getExtraMetadata() Table::getFragmentCount() Table::getFragmentData() Table::getFragmentDataLen() Table::getFragmentNodes() Table::getFragmentType() Table::getFrmData() Table::getFrmLength() Table::getHashMap() Table::getKValue() Table::getLinearFlag() Table::getLogging() Table::getMaxLoadFactor() Table::getMaxRows() Table::getMinLoadFactor() Table:getName() Table::getNoOfColumns() Table::getNoOfPrimaryKeys() Table::getObjectId() Table::getObjectStatus() Table::getObjectType() Table::getObjectVersion() Table::getPartitionBalance() Table::getPartitionBalanceString() Table::getPartitionId() Table::getPrimaryKey() Table::getRangeListData() Table::getRangeListDataLen() Table::getRowChecksumIndicator() Table::getRowGCIIndicator() Table::getSingleUserMode() Table::getTableId() Table::getTablespace() Table::getTablespaceData() Table::getTablespaceDataLen() Table::getTablespaceNames() Table::getTablespaceNamesLen() Table::hasDefaultValues() Table::setDefaultNoPartitionsFlag() Table::setExtraMetadata() Table::setFragmentCount() Table::setFragmentData() Table::setFragmentType() Table::setFrm() Table::setHashMap() Table::setKValue() Table::setLinearFlag() Table::setLogging() Table::setMaxLoadFactor() Table::setMaxRows() Table::setMinLoadFactor() Table::setName() Table::setObjectType() Table::setPartitionBalance() Table::setRangeListData() Table::setRowChecksumIndicator() Table::setRowGCIIndicator() Table::setSingleUserMode() Table::setStatusInvalid() Table::setTablespace() Table::setTablespaceData() Table::setTablespaceNames() Table::SingleUserMode Table::validate()


This section describes the Table class, which models a database table in the NDB API.

Parent class.  NdbDictionary

Child classes.  None

Description.  The Table class represents a table in an NDB Cluster database. This class extends the Object class, which in turn is an inner class of the NdbDictionary class.


It is possible using the NDB API to create tables independently of the MySQL server. However, it is usually not advisable to do so, since tables created in this fashion cannot be seen by the MySQL server. Similarly, it is possible using Table methods to modify existing tables, but these changes (except for renaming tables) are not visible to MySQL.

Calculating Table Sizes.  When calculating the data storage one should add the size of all attributes (each attribute consuming a minimum of 4 bytes) and well as 12 bytes overhead. Variable size attributes have a size of 12 bytes plus the actual data storage parts, with an additional overhead based on the size of the variable part. For example, consider a table with 5 attributes: one 64-bit attribute, one 32-bit attribute, two 16-bit attributes, and one array of 64 8-bit attributes. The amount of memory consumed per record by this table is the sum of the following:

  • 8 bytes for the 64-bit attribute

  • 4 bytes for the 32-bit attribute

  • 8 bytes for the two 16-bit attributes, each of these taking up 4 bytes due to right-alignment

  • 64 bytes for the array (64 * 1 byte per array element)

  • 12 bytes overhead

This totals 96 bytes per record. In addition, you should assume an overhead of about 2% for the allocation of page headers and wasted space. Thus, 1 million records should consume 96 MB, and the additional page header and other overhead comes to approximately 2 MB. Rounding up yields 100 MB.

Methods.  The following table lists the public methods of this class and the purpose or use of each method:

Table 2.86 Table class methods and descriptions

Name Description
Table() Class constructor
~Table() Destructor
addColumn() Adds a column to the table
aggregate() Computes aggregate data for the table
equal() Compares the table with another table
getColumn() Gets a column (by name) from the table
getDefaultNoPartitionsFlag() Checks whether the default number of partitions is being used
getFragmentCount() Gets the number of fragments for this table
getExtraMetadata() Gets extra metadata for this table
getFragmentData() Gets table fragment data (ID, state, and node group)
getFragmentDataLen() Gets the length of the table fragment data
getFragmentNodes() Gets IDs of data nodes on which fragments are located
getFragmentType() Gets the table's FragmentType
getFrmData() Gets the data from the table .FRM file
getFrmLength() Gets the length of the table's .FRM file
getHashMap() Gets the table's hash map.
getKValue() Gets the table's KValue
getLinearFlag() Gets the current setting for the table's linear hashing flag
getLogging() Checks whether logging to disk is enabled for this table
getMaxLoadFactor() Gets the table's maximum load factor
getMaxRows() Gets the maximum number of rows that this table may contain
getMinLoadFactor() Gets the table's minimum load factor
getName() Gets the table's name
getNoOfColumns() Gets the number of columns in the table
getNoOfPrimaryKeys() Gets the number of columns in the table's primary key.
getObjectId() Gets the table's object ID
getObjectStatus() Gets the table's object status
getObjectType() Removed in NDB 7.5.0 (Bug #47960, Bug #11756088)
getObjectVersion() Gets the table's object version
getPartitionBalance() Gets partition balance (fragment count type) used for this table (NDB 7.5.4 and later)
getPartitionBalanceString() Gets partition balance used for this table, as a string (NDB 7.5.4 and later)
getPartitionId() Gets a partition ID from a hash value
getPrimaryKey() Gets the name of the table's primary key
getRangeListData() Gets a RANGE or LIST array
getRangeListDataLen() Gets the length of the table RANGE or LIST array
getRowChecksumIndicator() Checks whether the row checksum indicator has been set
getRowGCIIndicator() Checks whether the row GCI indicator has been set
getSingleUserMode() Gets the SingleUserMode for this table
getTableId() Gets the table's ID
getTablespace() Gets the tablespace containing this table
getTablespaceData() Gets the ID and version of the tablespace containing the table
getTablespaceDataLen() Gets the length of the table's tablespace data
getTablespaceNames() Gets the names of the tablespaces used in the table fragments
hasDefaultValues() Determine whether table has any columns using default values
setDefaultNoPartitionsFlag() Toggles whether the default number of partitions should be used for the table
setExtraMetadata() Sets extra metadata for this table
getFragmentCount() Gets the number of fragments for this table
setFragmentData() Sets the fragment ID, node group ID, and fragment state
setFragmentType() Sets the table's FragmentType
setFrm() Sets the .FRM file to be used for this table
setHashMap() Sets the table's hash map.
setKValue() Set the KValue
setLinearFlag() Sets the table's linear hashing flag
setLogging() Toggle logging of the table to disk
setMaxLoadFactor() Set the table's maximum load factor (MaxLoadFactor)
setMaxRows() Sets the maximum number of rows in the table
setMinLoadFactor() Set the table's minimum load factor (MinLoadFactor)
setPartitionBalance() Sets the partition balance (fragment count type) for this table (NDB 7.5.4 and later)
setName() Sets the table's name
setObjectType() Removed in NDB 7.5.0 (Bug #47960, Bug #11756088)
setRangeListData() Sets LIST and RANGE partition data
setRowChecksumIndicator() Sets the row checksum indicator
setRowGCIIndicator() Sets the row GCI indicator
setSingleUserMode() Sets the SingleUserMode value for this table
setTablespace() Set the tablespace to use for this table
setTablespaceData() Sets the tablespace ID and version
setTablespaceNames() Sets the tablespace names for fragments
validate() Validates the definition for a new table prior to creating it

The assignment (=) operator is overloaded for this class, so that it always performs a deep copy.


As with other database objects, Table object creation and attribute changes to existing tables done using the NDB API are not visible from MySQL. For example, if you add a new column to a table using Table::addColumn(), MySQL cannot see the new column. The only exception to this rule with regard to tables is that a change of name of an existing NDB table using Table::setName() is visible to MySQL.

Types.  The Table class defines a single public type SingleUserMode.