2.3.36 The Table Class

2.3.36.1 The Table::SingleUserMode Type
2.3.36.2 Table Methods

Abstract

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 a MySQL Cluster database. This class extends the Object class, which in turn is an inner class of the NdbDictionary class.

Important

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:

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:

MethodPurpose / Use
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
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()Gets the table's object type (Object::Type)
getObjectVersion()Gets the table's object version
getPartitionId()Gets a partition ID from a has 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
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
setFragmentCount()Sets 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)
setName()Sets the table's name
setObjectType()Sets the table's object type
setRangeListData()Sets LIST and RANGE partition data
setRowChecksumIndicator()Sets the row checksum indicator
setRowGCIIndicator()Sets the row GCI indicator
setStatusInvalid() 
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

For detailed descriptions, signatures, and examples of use for each of these methods, see Section 2.3.36.2, “Table Methods”.

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

Class diagram.  This diagram shows all the available methods of the Table class:

Public methods of the Table class.