UENCE. See CREATE SEQUENCE and
Sequence Overview.

Atomic DDL
----------

MariaDB starting with 10.6.1
----------------------------
MariaDB 10.6.1 supports Atomic DDL. CREATE TABLE is atomic, except for CREATE
OR REPLACE, which is only crash safe.

Examples
--------

create table if not exists test (
a bigint auto_increment primary key,
name varchar(128) charset utf8,
key name (name(32))
) engine=InnoDB default charset latin1;

This example shows a couple of things:

* Usage of IF NOT EXISTS; If the table already existed, it will not be
created.  There will not be any error for the client, just a warning.
* How to create a PRIMARY KEY that is automatically generated.
* How to specify a table-specific character set and another for a column.
* How to create an index (name) that is only partly indexed (to save space).

The following clauses will work from MariaDB 10.2.1 only.

CREATE TABLE t1(
 a int DEFAULT (1+1),
 b int DEFAULT (a+1),
 expires DATETIME DEFAULT(NOW() + INTERVAL 1 YEAR),
 x BLOB DEFAULT USER()
);

URL: https://mariadb.com/kb/en/create-table/https://mariadb.com/kb/en/create-procedure/https://mariadb.com/kb/en/window-functions-columnstore-window-functions/https://mariadb.com/kb/en/system-versioned-tables/2020-10-03', '2020-10-07'),
 (2, 'Eusebius', '2020-10-04', '2020-10-06');
ERROR 1062 (23000): Duplicate entry '2-2020-10-06-2020-10-04' for key
'room_number'

Further Examples
----------------

The implicit change from NULL to NOT NULL:

CREATE TABLE `t2` (
 `id` int(11) DEFAULT NULL,
 `d1` datetime DEFAULT NULL,
 `d2` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

ALTER TABLE t2 ADD PERIOD FOR p(d1,d2);

SHOW CREATE TABLE t2\G
*************************** 1. row ***************************
   Table: t2
Create Table: CREATE TABLE `t2` (
 `id` int(11) DEFAULT NULL,
 `d1` datetime NOT NULL,
 `d2` datetime NOT NULL,
 PERIOD FOR `p` (`d1`, `d2`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1

Due to this constraint, trying to add a time period where null data already
exists will fail.

CREATE OR REPLACE TABLE `t2` (
 `id` int(11) DEFAULT NULL,
 `d1` datetime DEFAULT NULL,
 `d2` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

INSERT INTO t2(id) VALUES(1);

ALTER TABLE t2 ADD PERIOD FOR p(d1,d2);
ERROR 1265 (01000): Data truncated for column 'd1' at row 1

URL: https://mariadb.com/kb/en/application-time-periods/https://mariadb.com/kb/en/change-master-to/