SQL reference (MySQL and MariaDB dialects)
The language Raft DB's MySQL and MariaDB front-ends read, in the order of the MySQL Reference Manual: language structure, data types, operators, functions and the statements.
- Literals: How to write strings, numbers, hexadecimal and bit values, booleans, NULL and dates in a statement, and what Raft DB does differently from MySQL and MariaDB.
- Identifiers: How to name databases, tables, columns and other objects: quoting, characters, the 64 character limit, case, and the names Raft DB keeps for itself.
- Comments: The three comment forms, executable comments, and how they are treated.
- Reserved words: Which words Raft DB does not accept as an unquoted name, and how that differs from the long reserved lists of MySQL and MariaDB.
- Variables (user, local and system): User variables (@name), local variables of stored programs, and system variables (@@name, @@global.name, @@session.name): syntax, scope and what Raft DB supports.
- Expressions and operator precedence: What an expression can contain, how operators group, and where Raft DB's precedence or evaluation differs from MySQL.
- NULL handling: How NULL behaves in comparisons, logic, arithmetic, functions, aggregates, ordering, grouping and indexes.
- Collation and case sensitivity: Raft DB compares text without regard to case, like the default collation of both servers; the collations and character sets it lists, and what COLLATE does and does not do.
- SQL modes: The sql_mode variable: its default in each dialect, which modes change what Raft DB does (strict, zero dates, ONLY_FULL_GROUP_BY) and which are only stored.
- Data types: Every column type Raft DB accepts in CREATE TABLE, with its range or length, its aliases, and the types it does not support yet.
- Integer types: TINYINT to BIGINT with UNSIGNED, BOOL, SERIAL and AUTO_INCREMENT: ranges, behaviour at the limits and the differences between the dialects.
- DECIMAL, FLOAT and DOUBLE: Exact numbers (DECIMAL up to 65 digits) and approximate numbers (FLOAT, DOUBLE): syntax, rounding, limits and how arithmetic behaves.
- BIT type: BIT(M) columns of 1 to 64 bits, how they are written, shown and compared.
- Character types: CHAR, VARCHAR and the TEXT family, their length limits, the type aliases (NVARCHAR, LONG and others) and how character sets are handled.
- Binary types: BINARY, VARBINARY and the BLOB family: how Raft DB stores them, the UTF-8 limit and how they differ from MySQL and MariaDB.
- ENUM and SET: ENUM and SET columns: syntax, how values are matched and stored, the index form, and errors.
- Date and time types: DATE, DATETIME, TIMESTAMP, TIME and YEAR with fractional seconds: accepted forms, ranges, rounding and zero dates.
- JSON type: The JSON column type in the MySQL and MariaDB dialects: validation, storage as text, paths and the differences from the servers.
- UUID, INET4 and INET6 types: The MariaDB types UUID, INET4 and INET6: accepted forms, the form they are kept in, errors, and the difference from MySQL.
- Type conversion, out-of-range values and strict mode: How Raft DB converts between numbers, text and dates in expressions, comparisons and column stores, and what happens to a value that does not fit.
- Operators: All operators Raft DB reads, grouped by kind, with the precedence table and the assignment operators.
- Comparison operators: =, <=>, <>, <, BETWEEN, IN, IS, row comparisons and ANY, SOME and ALL with subqueries: what each returns, and how text and NULL are compared.
- Arithmetic and logical operators: +, -, *, /, DIV, %, MOD, unary minus and AND, OR, XOR, NOT: exactness, division, results and three-valued logic.
- Bit operators: &, |, ^, ~, << and >> on unsigned 64-bit numbers, and the BIT_ functions.
- String operators: LIKE, REGEXP and RLIKE, COLLATE and BINARY: patterns, case, wildcards and what is not supported yet.
- JSON operators (->, ->> and MEMBER OF): The MySQL operators col->'$.path', col->>'$.path' and value MEMBER OF(array), and what the MariaDB dialect does instead.
- Functions and operators: The built-in functions of Raft DB by category, an alphabetical index of every function, and how the MySQL and MariaDB dialects differ.
- String functions: Every string function Raft DB runs: syntax, one example each, and where it differs from MySQL or MariaDB.
- Numeric functions: The mathematical functions of Raft DB: rounding, powers, logarithms, trigonometry and number bases.
- Date and time functions: The date and time functions of Raft DB: current time, parts of a date, arithmetic with intervals, formatting and parsing.
- Control flow functions: CASE, IF, IFNULL, NULLIF, COALESCE and ISNULL: choosing a value by a condition or by NULL.
- Cast and conversion functions: CAST, CONVERT and BINARY: converting a value to another type.
- Aggregate functions: COUNT, SUM, AVG, MIN, MAX, GROUP_CONCAT, the standard deviation and variance family, the BIT_ functions and JSON_ARRAYAGG, with GROUP BY and WITH ROLLUP.
- Window functions: ROW_NUMBER, RANK, DENSE_RANK, NTILE, LAG, LEAD, FIRST_VALUE, LAST_VALUE, NTH_VALUE and the aggregates with OVER, with the window and frame syntax.
- JSON functions: Every JSON_ function of Raft DB, with the differences between the MySQL and MariaDB dialect and the JSON operators.
- Regular expression functions: REGEXP, RLIKE and REGEXP_LIKE, REGEXP_INSTR, REGEXP_REPLACE and REGEXP_SUBSTR: the pattern syntax Raft DB reads and the argument forms of each dialect.
- Encryption and hash functions: MD5, SHA1 and SHA2: the hash functions Raft DB has, and the encryption functions it does not have.
- Information functions: VERSION, DATABASE, USER, CURRENT_USER, CONNECTION_ID, LAST_INSERT_ID, ROW_COUNT, FOUND_ROWS, CHARSET and COLLATION.
- Sequence functions: NEXTVAL, LASTVAL and SETVAL, with the NEXT VALUE FOR and PREVIOUS VALUE FOR forms.
- Stored function calls: How to call a function made with CREATE FUNCTION in a statement, how Raft DB evaluates the call, and the limits.
- Functions that are not supported yet: The well-known MySQL and MariaDB functions and function-like syntax that Raft DB does not run, and the functions it accepts but does not act on.
- Miscellaneous functions: ANY_VALUE, UUID, UUID_SHORT, INET_ATON and its relatives, VALUES, and the lock and sleep functions that Raft DB accepts without acting.
- Spatial types and functions: POINT, LINESTRING, POLYGON and the other spatial types, WKT and WKB, the ST_ and MBR functions, SPATIAL index definitions, and what is refused.
- CREATE DATABASE, DROP DATABASE and SHOW CREATE DATABASE: How to create, remove and describe a database through the MySQL and MariaDB front-ends, and what the character set options do (nothing).
- CREATE TABLE statement: The CREATE TABLE grammar that the Raft DB parser accepts, with columns, keys, constraints, table options and the MySQL and MariaDB differences.
- ALTER TABLE statement: The changes ALTER TABLE accepts, how the checks and the row rewrite work, and the changes that are refused.
- DROP TABLE statement: How DROP TABLE and DROP TEMPORARY TABLE work, with the foreign-key and view rules.
- CREATE INDEX and DROP INDEX statements: Create and drop plain, unique, prefix, invisible and functional indexes, and how they map to ALTER TABLE.
- INSERT statement: INSERT with VALUES, SET and SELECT, IGNORE, ON DUPLICATE KEY UPDATE and RETURNING, as the Raft DB parser accepts it.
- UPDATE statement: Single-table and multi-table UPDATE with ORDER BY and LIMIT, as the Raft DB parser accepts it.
- DELETE statement: Single-table and multi-table DELETE with ORDER BY, LIMIT and RETURNING, as the Raft DB parser accepts it.
- SELECT statement: The SELECT grammar of Raft DB: joins, grouping, ROLLUP, windows, subqueries, LIMIT, INTO and locking clauses, with the differences between MySQL and MariaDB.
- UNION, EXCEPT, INTERSECT, VALUES and TABLE: Set operations over query results, the VALUES and TABLE statements, and how ORDER BY and LIMIT attach to them.
- WITH (common table expressions): Non-recursive and recursive common table expressions in SELECT, INSERT, UPDATE, DELETE and CREATE TABLE ... AS.
- START TRANSACTION, COMMIT, ROLLBACK and SAVEPOINT: The transaction statements of the MySQL and MariaDB front-ends, what they guarantee (atomic) and what they do not (isolation).
- PREPARE, EXECUTE and DEALLOCATE PREPARE: SQL-level prepared statements, EXECUTE IMMEDIATE (MariaDB) and the binary prepared-statement protocol used by drivers.
- SHOW statements: Every SHOW statement the Raft DB parser accepts, what it returns here, and the SHOW statements that are refused.
- CREATE VIEW, ALTER VIEW and DROP VIEW: Stored queries that are read as derived tables, with the rules for updatable views and the limits of this version.
- CREATE PROCEDURE, CREATE FUNCTION, CALL and the stored program language: Stored procedures and functions: definitions, CALL, variables, flow control, cursors, handlers, SIGNAL and the limits of this version.
- CREATE TRIGGER and DROP TRIGGER: Row triggers BEFORE and AFTER INSERT, UPDATE and DELETE with NEW and OLD, where they run and what is not done yet.
- CREATE SEQUENCE, ALTER SEQUENCE and NEXTVAL: MariaDB sequences: creating and changing them, NEXTVAL, LASTVAL, SETVAL and sequences as column defaults.
- INFORMATION_SCHEMA tables: The information_schema tables the front-ends serve, which ones have rows, and how they are generated.
- System variables: How system variables are listed, read and set in the MySQL and MariaDB front-ends, and which ones change behaviour.
- REPLACE statement: REPLACE as delete-then-insert on a key clash, with the privileges and triggers it involves.
- TRUNCATE TABLE statement: TRUNCATE TABLE empties a table by dropping and recreating it, and resets the AUTO_INCREMENT counter.
- RETURNING clause: INSERT, REPLACE and DELETE ... RETURNING return the rows they wrote or removed as a result set (MariaDB form).
- Temporary tables: CREATE TEMPORARY TABLE and DROP TEMPORARY TABLE, how a session's temporary tables hide base tables, and their limits.
- CHECK constraints: CHECK constraints on columns and tables, when they are tested, the errors they give and the known gaps.
- Generated columns: GENERATED ALWAYS AS columns, VIRTUAL and STORED, when they are computed and the rules and gaps.
- Invisible columns and indexes: INVISIBLE and VISIBLE for columns and indexes, what an invisible column is left out of, and the gaps.
- Functional indexes: Indexes on expressions, written as a parenthesised key part, and how they are built from hidden generated columns.
- CREATE TABLE ... SELECT and CREATE TABLE ... LIKE: Making a table from the columns of a query or from the definition of another table, with the type rules and the known gaps.
- Foreign keys: FOREIGN KEY constraints with enforcement, the referential actions, and the limits of this version.
- Statements not supported yet: The statements and clauses that the Raft DB front-ends refuse today with error 1235 or 1064, and how to tell the two apart.
- SET statement: SET for system variables, user variables, character sets, passwords and transaction characteristics.
- USE and DO: USE selects the default database; DO evaluates expressions and discards the result.
- DESCRIBE and EXPLAIN: DESCRIBE lists the columns of a table; EXPLAIN gives a simple plan table. What each returns here and what is refused.
- ANALYZE, OPTIMIZE, CHECK and REPAIR TABLE: The table maintenance statements answer as a healthy InnoDB table does; they change nothing.
- User and privilege statements: CREATE USER, ALTER USER, DROP USER, RENAME USER, SET PASSWORD, GRANT, REVOKE and SHOW GRANTS, with the privilege checks and the refused forms.
- FLUSH, LOCK TABLES, KILL and LOAD DATA: Statements that are accepted and do nothing (FLUSH, LOCK TABLES), and statements that are refused (KILL, LOAD DATA).
- Temporal tables (MariaDB): System-versioned tables (WITH SYSTEM VERSIONING, FOR SYSTEM_TIME, DELETE HISTORY) and application-time periods (PERIOD FOR, FOR PORTION OF, WITHOUT OVERLAPS) of the MariaDB dialect.