SERIAL
This page is part of MariaDB's Documentation.
The parent of this page is: Data Types for MariaDB Xpand
Topics on this page:
Overview
This is an alias for BIGINT UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE.
USAGE
SERIAL
DETAILS
Data Type | Minimum Value | Maximum Value |
|---|---|---|
|
|
|
AUTO_INCREMENT vs. AUTO_UNIQUE
MariaDB Xpand can provide better performance by using AUTO_UNIQUE constraints instead of AUTO_INCREMENT. Therefore, if performance is a concern, MariaDB recommends defining columns as BIGINT(0) UNSIGNED AUTO_UNIQUE NOT NULL, rather than using the SERIAL data type.
For additional information about AUTO_UNIQUE constraints, see "AUTO_UNIQUE Constraints with MariaDB Xpand".
EXAMPLES
While Xpand accepts the SERIAL data type on table create, it is silently replaced with BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE:
CREATE TABLE serial_example (
id SERIAL PRIMARY KEY,
data VARCHAR(32)
);
SHOW CREATE TABLE serial_example\G
*************************** 1. row ***************************
Table: serial_example
Create Table: CREATE TABLE `serial_example` (
`id` bigint(20) unsigned not null AUTO_INCREMENT,
`data` varchar(32) CHARACTER SET utf8,
PRIMARY KEY (`id`) /*$ PAYLOAD (`data`) DISTRIBUTE=1 */
) AUTO_INCREMENT=1 CHARACTER SET utf8 /*$ SLICES=3 */
