How to use the sequence object introduced in MariaDB 10.0.3

How to use the sequence object introduced in MariaDB 10.0.3

Version

Version
10.3.36-MariaDB

Sequence storage engine confirmation

Sequence storage engine has been added since MariaDB 10.0.3.

SHOW engines;
EngineSupportCommentTransactionsXASavepoints
CSVYESStores tables as CSV filesNONONO
MRG_MyISAMYESCollection of identical MyISAM tablesNONONO
MEMORYYESHash based, stored in memory, useful for temporary tablesNONONO
MyISAMYESNon-transactional engine with good performance and small data footprintNONONO
SEQUENCEYESGenerated tables filled with sequential valuesYESNOYES
InnoDBDEFAULTSupports transactions, row-level locking, foreign keys and encryption for tablesYESYESYES
AriaYESCrash-safe tables with MyISAM heritageNONONO
PERFORMANCE_SCHEMAYESPerformance SchemaNONONO

The SEQUENCE row has been added, since it is a plugin for MariaDB and MySQL does not have this functionality.

ha_sequence plugin usage in MySQL
Isthereanypossibilitytousetheha_sequencepluginprovidedbyMariaDBinMySQL(OrdoesasimilarpluginexistforMySQL?Iwantto...

How to use sequence objects

Dynamically change the table names and assign sequences as follows

seq_[FROM]_to_[TO]

Examples from 0 to 6.

>SELECT seq FROM seq_0_to_6
0
1
2
3
4
5
6

The default is to increment by 1, but can be specified as follows

seq_[FROM]to[TO]step[STEP]

Example of increasing by 3.

>SELECT seq FROM seq_0_to_9_step_3
0
3
6
9

It is also possible to JOIN these virtual tables together and do other complex things.

This feature may have been added because MySQL does not have a feature like rowid in Oracle.

コメント

タイトルとURLをコピーしました