create circular table
Create a new circular database table
Syntax
create_circular_table: CREATE CIRCULAR TABLE [database_name.]table_name [OF] MAXROWS [=] maxrows_num (column_def[, column_def]...[, tab_constraint]...)
Description
The CREATE CIRCULAR TABLE statement is used to define a table with a limited number of rows. With circular tables, when the table reaches the row limit RDM will continue to allow new rows to be inserted. These new rows will overwrite existing ones, starting with the oldest.
RDM does not allow explicit deletion of rows in a circular table.
It is not advisable to have a FOREIGN KEY in a circular table reference a PRIMARY KEY in a circular table with the ON DELETE CASCADE trigger action. When the primary table is full new inserts will delete old rows in the primary table. Those old row deletes will trigger deletes in the foreign table of any rows that reference the row in the primary that is being deleted. The delete in the foreign table will fail because the engine will not allow rows in a circular table to be explicitly deleted, even if it is by the engine when a triggered action is being performed.
There are two ways to define constraints: table constraints and column constraints. A column constraint is defined as part of a column definition. A table constraint definition is not tied to a particular column, and it can encompass more than one column. Every column constraint can also be written as a table constraint; a column constraint is only a notational convenience for use when the constraint only affects one column.
Components
table_name | The name of the table to be created. |
column_def | The name and data type of a column to be created in the new table. For more information on the structure of the column definition components, refer to the Column Definitions section. |
tab_constraint | Optional table constraints that can be declared (keys, foreign keys, or check clauses). For more information on table constraints, refer to the Table Constraint Declarations section. |
Example
create circular table readings of maxrows = 10000( r_time timestamp, r_value uint32 );
See Also