A database table is a collection of two-dimensional arrays that represent and store the relationships between different objects in a database. This topic describes database objects related to database tables and the use of database tables, such as table storage, table compression, table groups, and temporary tables.
A table is the basic unit of data organization in a database. It consists of vertical columns and horizontal rows. For example, a table named Authors is created to store information about authors. Each column stores a specific attribute of all authors, such as their names. Each row contains all attributes of a specific author, such as the first name, last name, and address of the author. The number of columns in a table is specified when the table is created, and the columns are identified by column names. The number of rows can dynamically change.
Tables are divided into normal tables and temporary tables. In the MySQL mode of OceanBase Database, the lifecycle of temporary tables only exists during the session period. All temporary tables created when the session is disconnected are automatically dropped. For example, a temporary table created in sess#1 is invisible to sess#2.
You can create temporary tables with the same name in different sessions. Temporary tables can also have the same name as an existing normal table. However, you cannot create views based on temporary tables. If a temporary table and a normal table have the same name, operations such as SHOW CREATET TABLE, DESC, and DML act only on the temporary table, and the normal table is hidden.
Notice
Starting from OceanBase Database V4.1.0 BP4, the temporary table feature is disabled in MySQL mode.
Columns
In a database, a column in a table records the values of an attribute field, and the attribute name is the column name. Apart from the column name, information about a column also includes the data type and maximum length (precision).
In addition to normal columns, the MySQL mode of OceanBase Database also supports virtual columns (also known as generated columns) and auto-increment columns.
Virtual columns do not provide physical storage space as regular columns do. Values in a virtual column are calculated by expressions or functions defined for the column.
Auto-increment columns satisfy the following rules:
They are globally unique across multiple partitions.
The column number increases in sequence within a statement.
Their generated values are larger than the values inserted by users.
Rows
In a database, a row stores the values of all columns of a specific record. Simply put, a database consists of columns and rows. Each row in a table stores a set of related data in the same structure.
For example, a table is created to store information about companies. Each row contains a set of data about a specific company. Each column contains data about a specific attribute of all companies, such as the company name, address, or tax number.