Package org.h2.table

# Class MetaTable

java.lang.Object
org.h2.engine.DbObject
org.h2.schema.SchemaObject
org.h2.table.Table
org.h2.table.MetaTable

All Implemented Interfaces:
  `HasSQL`

Direct Known Subclasses:
  `InformationSchemaTable`, `InformationSchemaTableLegacy`, `PgCatalogTable`

public abstract class MetaTable extends Table
This class is responsible to build the database metadata pseudo tables.

## Field Summary

Fields
Modifier and Type
Field
Description
`protected int`
`indexColumn`
The indexed column.
`protected MetaIndex`
`metaIndex`
The index for this table.
`static final long`
`ROW_COUNT_APPROXIMATION`
The approximate number of rows of a meta table.
`protected final int`
`type`
The table type.

### Fields inherited from class org.h2.table.Table

`columns, compareMode, EXCLUSIVE_LOCK, READ_LOCK, TYPE_CACHED, TYPE_MEMORY, WRITE_LOCK`

### Fields inherited from class org.h2.engine.DbObject

`AGGREGATE, comment, COMMENT, CONSTANT, CONSTRAINT, database, DOMAIN, FUNCTION_ALIAS, INDEX, RIGHT, ROLE, SCHEMA, SEQUENCE, SETTING, SYNONYM, TABLE_OR_VIEW, trace, TRIGGER, USER`

### Fields inherited from interface org.h2.util.HasSQL

`ADD_PLAN_INFORMATION, DEFAULT_SQL_FLAGS, NO_CASTS, QUOTE_ONLY_WHEN_REQUIRED, REPLACE_LOBS_FOR_TRACE, TRACE_SQL_FLAGS`

## Constructor Summary

Constructors
Modifier
Constructor
Description
`protected`
`MetaTable(Schema schema, int id, int type)`
Create a new metadata table.

## Method Summary

Modifier and Type
Method
Description
`protected final void`
`add(SessionLocal session, ArrayList<Row> rows, Object... stringsOrValues)`
Add a row to a list.
`final Index`
`addIndex(SessionLocal session, String indexName, int indexId, IndexColumn[] cols, int uniqueColumnCount, IndexType indexType, boolean create, String indexComment)`
Create an index for this table
`final void`
`addRow(SessionLocal session, Row row)`
Add a row to the table and all indexes.
`final boolean`
`canDrop()`
Check if this table can be dropped.
`boolean`
`canGetRowCount(SessionLocal session)`
Check if the row count can be retrieved quickly.
`final boolean`
`canReference()`
Check if this table can be referenced.
`protected final boolean`
`checkIndex(SessionLocal session, String value, Value indexFrom, Value indexTo)`
Checks index conditions.
`final void`
`checkRename()`
Check if renaming is allowed.
`final void`
`checkSupportAlter()`
Check if this table supports ALTER TABLE.
`final void`
`close(SessionLocal session)`
Close the table object and flush changes.
`protected final Column`
`column(String name, TypeInfo type)`
Creates a column with the specified name and data type.
`abstract ArrayList<Row>`
`generateRows(SessionLocal session, SearchRow first, SearchRow last)`
Generate the data for the given metadata table using the given first and last row filters.
`protected final Stream<Constraint>`
`getAllConstraints(SessionLocal session)`
Get all constraints of this database, including constraints of local temporary tables for the session.
`protected final Stream<Table>`
`getAllTables(SessionLocal session, Value indexFrom, Value indexTo)`
Get all tables of this database, including local temporary tables for the session.
`final String`
`getCreateSQL()`
Construct the CREATE ...
`final List<Index>`
`getIndexes()`
Get all indexes for this table.
`long`
`getRowCount(SessionLocal session)`
Get the row count for this table.
`long`
`getRowCountApproximation(SessionLocal session)`
Get the approximated row count for this table.
`final Index`
`getScanIndex(SessionLocal session)`
Get the scan index to iterate through all rows.
`final TableType`
`getTableType()`
Get the table type name
`protected final String`
`identifier(String s)`
If needed, convert the identifier to lower case.
`final boolean`
`isDeterministic()`
Check if the table is deterministic.
`boolean`
`isInsertable()`
Returns whether this table is insertable.
`final void`
`removeChildrenAndResources(SessionLocal session)`
Delete all dependent children objects and resources of this object.
`final void`
`removeRow(SessionLocal session, Row row)`
Remove a row from the table and all indexes.
`protected void`
`setColumns(Column[] columns)`
`protected final void`
`setMetaTableName(String upperName)`
`final long`
`truncate(SessionLocal session)`
Remove all rows from the table and indexes.

### Methods inherited from class org.h2.table.Table

`addConstraint, addDependencies, addDependentMaterializedView, addDependentView, addSequence, addSynonym, addTrigger, canTruncate, checkDeadlock, checkWritingAllowed, compareValues, convertInsertRow, convertUpdateRow, createRow, doesColumnExist, dropMultipleColumnsConstraintsAndIndexes, findColumn, findPrimaryKey, fire, fireAfterRow, fireBeforeRow, fireRow, getBestPlanItem, getCheckForeignKeyConstraints, getChildren, getColumn, getColumn, getColumn, getColumns, getCompareMode, getConstraints, getDependentMaterializedViews, getDependentViews, getDiskSpaceUsed, getIdentityColumn, getIndex, getIndexForColumn, getMainIndexColumn, getMaxDataModificationId, getNullRow, getOnCommitDrop, getOnCommitTruncate, getPrimaryKey, getRow, getRowFactory, getRowIdColumn, getScanIndex, getSQLTableType, getTemplateRow, getTemplateSimpleRow, getTriggers, getType, getVisibleColumns, hasSelectTrigger, isGlobalTemporary, isLockedExclusively, isLockedExclusivelyBy, isPersistData, isPersistIndexes, isQueryComparable, isRowLockable, isView, lock, lockRow, removeColumnExpressionsDependencies, removeConstraint, removeDependentMaterializedView, removeDependentView, removeIndex, removeIndexOrTransferOwnership, removeSequence, removeSynonym, removeTrigger, rename, renameColumn, setCheckForeignKeyConstraints, setOnCommitDrop, setOnCommitTruncate, unlock, updateRow, updateRows`

### Methods inherited from class org.h2.schema.SchemaObject

`getSchema, getSQL, getSQL`

### Methods inherited from class org.h2.engine.DbObject

`equals, getComment, getCreateSQLForCopy, getCreateSQLForMeta, getDatabase, getDropSQL, getId, getModificationId, getName, hashCode, invalidate, isTemporary, isValid, setComment, setModified, setObjectName, setTemporary, toString`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface org.h2.util.HasSQL

`getTraceSQL`

## Field Details

### ROW_COUNT_APPROXIMATION

public static final long ROW_COUNT_APPROXIMATION
The approximate number of rows of a meta table.

See Also:
  - Constant Field Values

### type

protected final int type
The table type.

### indexColumn

protected int indexColumn
The indexed column.

### metaIndex

protected MetaIndex metaIndex
The index for this table.

## Constructor Details

### MetaTable

protected MetaTable(Schema schema, int id, int type)
Create a new metadata table.

Parameters:
  `schema` - the schema
  `id` - the object id
  `type` - the meta table type

## Method Details

### setColumns

protected void setColumns(Column[] columns)

Overrides:
  `setColumns` in class `Table`

### setMetaTableName

protected final void setMetaTableName(String upperName)

### column

protected final Column column(String name, TypeInfo type)
Creates a column with the specified name and data type.

Parameters:
  `name` - the uppercase column name
  `type` - the data type
Returns:
  the column

### getCreateSQL

public final String getCreateSQL()
Description copied from class: `DbObject`
Construct the CREATE ... SQL statement for this object.

Specified by:
  `getCreateSQL` in class `DbObject`
Returns:
  the SQL statement

### addIndex

public final Index addIndex(SessionLocal session, String indexName, int indexId, IndexColumn[] cols, int uniqueColumnCount, IndexType indexType, boolean create, String indexComment)
Description copied from class: `Table`
Create an index for this table

Specified by:
  `addIndex` in class `Table`
Parameters:
  `session` - the session
  `indexName` - the name of the index
  `indexId` - the id
  `cols` - the index columns
  `uniqueColumnCount` - the count of unique columns
  `indexType` - the index type
  `create` - whether this is a new index
  `indexComment` - the comment
Returns:
  the index

### identifier

protected final String identifier(String s)
If needed, convert the identifier to lower case.

Parameters:
  `s` - the identifier to convert
Returns:
  the converted identifier

### checkIndex

protected final boolean checkIndex(SessionLocal session, String value, Value indexFrom, Value indexTo)
Checks index conditions.

Parameters:
  `session` - the session
  `value` - the value
  `indexFrom` - the lower bound of value, or `null`
  `indexTo` - the higher bound of value, or `null`
Returns:
  whether row should be included into result

### getAllTables

protected final Stream<Table> getAllTables(SessionLocal session, Value indexFrom, Value indexTo)
Get all tables of this database, including local temporary tables for the session.

Parameters:
  `session` - the session
  `indexFrom` - first value or `null`
  `indexTo` - last value or `null`
Returns:
  the stream of tables

### getAllConstraints

protected final Stream<Constraint> getAllConstraints(SessionLocal session)
Get all constraints of this database, including constraints of local temporary tables for the session.

Parameters:
  `session` - the session
Returns:
  the stream of constraints

### generateRows

public abstract ArrayList<Row> generateRows(SessionLocal session, SearchRow first, SearchRow last)
Generate the data for the given metadata table using the given first and last row filters.

Parameters:
  `session` - the session
  `first` - the first row to return
  `last` - the last row to return
Returns:
  the generated rows

### isInsertable

public boolean isInsertable()
Description copied from class: `Table`
Returns whether this table is insertable.

Overrides:
  `isInsertable` in class `Table`
Returns:
  whether this table is insertable

### removeRow

public final void removeRow(SessionLocal session, Row row)
Description copied from class: `Table`
Remove a row from the table and all indexes.

Specified by:
  `removeRow` in class `Table`
Parameters:
  `session` - the session
  `row` - the row

### addRow

public final void addRow(SessionLocal session, Row row)
Description copied from class: `Table`
Add a row to the table and all indexes.

Specified by:
  `addRow` in class `Table`
Parameters:
  `session` - the session
  `row` - the row

### removeChildrenAndResources

public final void removeChildrenAndResources(SessionLocal session)
Description copied from class: `DbObject`
Delete all dependent children objects and resources of this object.

Overrides:
  `removeChildrenAndResources` in class `Table`
Parameters:
  `session` - the session

### close

public final void close(SessionLocal session)
Description copied from class: `Table`
Close the table object and flush changes.

Specified by:
  `close` in class `Table`
Parameters:
  `session` - the session

### add

protected final void add(SessionLocal session, ArrayList<Row> rows, Object... stringsOrValues)
Add a row to a list.

Parameters:
  `session` - the session
  `rows` - the original row list
  `stringsOrValues` - the values, or strings

### checkRename

public final void checkRename()
Description copied from class: `DbObject`
Check if renaming is allowed. Does nothing when allowed.

Overrides:
  `checkRename` in class `DbObject`

### checkSupportAlter

public final void checkSupportAlter()
Description copied from class: `Table`
Check if this table supports ALTER TABLE.

Specified by:
  `checkSupportAlter` in class `Table`

### truncate

public final long truncate(SessionLocal session)
Description copied from class: `Table`
Remove all rows from the table and indexes.

Specified by:
  `truncate` in class `Table`
Parameters:
  `session` - the session
Returns:
  number of removed rows, possibly including uncommitted rows

### getRowCount

public long getRowCount(SessionLocal session)
Description copied from class: `Table`
Get the row count for this table.

Specified by:
  `getRowCount` in class `Table`
Parameters:
  `session` - the session
Returns:
  the row count

### canGetRowCount

public boolean canGetRowCount(SessionLocal session)
Description copied from class: `Table`
Check if the row count can be retrieved quickly.

Specified by:
  `canGetRowCount` in class `Table`
Parameters:
  `session` - the session
Returns:
  true if it can

### canDrop

public final boolean canDrop()
Description copied from class: `Table`
Check if this table can be dropped.

Specified by:
  `canDrop` in class `Table`
Returns:
  true if it can

### getTableType

public final TableType getTableType()
Description copied from class: `Table`
Get the table type name

Specified by:
  `getTableType` in class `Table`
Returns:
  the table type name

### getScanIndex

public final Index getScanIndex(SessionLocal session)
Description copied from class: `Table`
Get the scan index to iterate through all rows.

Specified by:
  `getScanIndex` in class `Table`
Parameters:
  `session` - the session
Returns:
  the index

### getIndexes

public final List<Index> getIndexes()
Description copied from class: `Table`
Get all indexes for this table.

Specified by:
  `getIndexes` in class `Table`
Returns:
  the list of indexes

### getRowCountApproximation

public long getRowCountApproximation(SessionLocal session)
Description copied from class: `Table`
Get the approximated row count for this table.

Specified by:
  `getRowCountApproximation` in class `Table`
Parameters:
  `session` - the session
Returns:
  the approximated row count

### isDeterministic

public final boolean isDeterministic()
Description copied from class: `Table`
Check if the table is deterministic.

Specified by:
  `isDeterministic` in class `Table`
Returns:
  true if it is

### canReference

public final boolean canReference()
Description copied from class: `Table`
Check if this table can be referenced.

Overrides:
  `canReference` in class `Table`
Returns:
  true if it can