MariaDB is a relational database management system that was created in 2009 as a fork of MySQL. The fork was triggered by Oracle Corporation's acquisition of Sun Microsystems, which owned MySQL at the time. MySQL's original creator Michael "Monty" Widenius started the MariaDB project to ensure that development would continue as open and community-driven. The name "Maria" comes from Widenius's daughter, just as "My" in MySQL is named after his older daughter.
The MariaDB Foundation maintains the project as a non-profit organization. MariaDB is compatible with MySQL: the same client tools, drivers, and most SQL statements work in both systems.
MariaDB can be downloaded from: https://mariadb.org/download/
Although MariaDB is largely compatible with MySQL, it includes several SQL features that MySQL does not have or that behave differently.
Since MariaDB 10.3, it supports SQL:2011 standard system-versioned tables
(WITH SYSTEM VERSIONING). Every row in the table automatically retains its full change history,
meaning you can query what the data looked like at any point in time.
MySQL does not support this feature.
CREATE TABLE order (
id INT PRIMARY KEY,
amount DECIMAL(10,2),
status VARCHAR(20)
) WITH SYSTEM VERSIONING;
-- Show what the order table looked like one week ago
SELECT * FROM order
FOR SYSTEM_TIME AS OF (NOW() - INTERVAL 7 DAY);
MariaDB 10.3+ supports SEQUENCE objects in the same way as PostgreSQL and SQL Server. A sequence is a database object that produces consecutive numbers independently of any table.
MySQL has no SEQUENCE support. The equivalent is achieved using an AUTO_INCREMENT column.
A key advantage over AUTO_INCREMENT is that one sequence can be shared across multiple tables.
This means no two rows in the entire database will share the same id value, regardless of which table they belong to.
This is useful for example in audit logs, where rows from different tables are combined and the id must be unique across the whole database.
CREATE SEQUENCE global_seq START WITH 1;
-- The id column has no AUTO_INCREMENT; the sequence provides the value
CREATE TABLE customer (
id INT PRIMARY KEY,
name VARCHAR(100)
);
CREATE TABLE purchase (
id INT PRIMARY KEY,
amount DECIMAL(10,2),
status VARCHAR(20)
);
INSERT INTO customer (id, name) VALUES (NEXT VALUE FOR global_seq, 'Alice'); -- gets id 1
INSERT INTO purchase (id, amount, status) VALUES (NEXT VALUE FOR global_seq, 149.90, 'new'); -- gets id 2
INSERT INTO customer (id, name) VALUES (NEXT VALUE FOR global_seq, 'Bob'); -- gets id 3
INSERT INTO purchase (id, amount, status) VALUES (NEXT VALUE FOR global_seq, 89.00, 'new'); -- gets id 4
MariaDB 10.3+ supports invisible columns.
SELECT * does not return them, but the column still exists and can be referenced by name.
This is useful for internal technical columns that should not be exposed to the application.
MySQL 8.0.23+ also added support for INVISIBLE columns, but the feature was available in MariaDB earlier.
CREATE TABLE customer (
id INT PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(100),
modified TIMESTAMP INVISIBLE DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);
SELECT * FROM customer; -- modified column is not returned
SELECT *, modified FROM customer; -- visible when referenced explicitly
MySQL 5.7+ includes a native JSON data type that stores data in a binary format and provides JSON functions for path-based queries.
In MariaDB, JSON is an alias for LONGTEXT. Values are stored as plain text,
but a JSON_VALID() check can be added via a CHECK constraint.
MariaDB's JSON functions (JSON_VALUE(), JSON_EXTRACT(), etc.) work
practically the same as in MySQL.
-- Works in both, but internal storage differs
CREATE TABLE product (
id INT PRIMARY KEY,
data JSON
);
INSERT INTO product VALUES (1, '{"name": "coffee", "price": 4.50}');
SELECT JSON_VALUE(data, '$.name') AS name FROM product;