Structure and Syntax

MatrixOne uses a MySQL-like SQL dialect. When writing statements, pay attention to comment syntax, identifier rules, and the distinction between reserved keywords and ordinary keywords.

Comments

Three common comment forms are supported:

Form

Description

# ...

From # to the end of the line

-- ...

Two hyphens followed by at least one space or control character, through the end of the line

/* ... */

C-style comments, which can span lines or appear inside an expression

SELECT 100 - 99;   -- End-of-line comment
SELECT 100 - 99;   # Also an end-of-line comment
SELECT 100 /* Inline comment */ - 99;

Identifiers

Identifiers such as database, table, and column names:

  • Can generally contain letters, numbers, and underscores. Do not start an unquoted identifier with a number.

  • Must be enclosed in backticks when a reserved keyword is used as an identifier, for example, `select` or `order`.

  • Even in qualified names such as database.table, reserved keywords should be—and in MatrixOne usually must be—enclosed in backticks. Avoid reserved words when creating databases and tables.

-- Incorrect: select is a reserved keyword
CREATE TABLE select (a INT);

-- Correct
CREATE TABLE `select` (a INT);

Non-reserved keywords, including some MatrixOne extensions, can usually be used directly as identifiers. If you are unsure, enclosing them in backticks is the safest approach.

Keywords

  • Keyword: A word with special meaning in SQL, such as SELECT, UPDATE, or DELETE.

  • Reserved keyword: Must be enclosed in backticks when used as an identifier, or parsing fails.

  • Non-reserved keyword: Can generally be used directly as an identifier.

The MatrixOne reserved-word set is broadly similar to MySQL and includes some MatrixOne-specific reserved words. Source documentation often marks differences from MySQL, such as CONFIG and CURRENT_ROLE. The complete list can change slightly between versions. When writing DDL:

  1. Prefer clear, business-specific names that are not reserved.

  2. If you must use a reserved word, consistently enclose it in backticks.

  3. If the client reports SQL parser error near a word, first check whether an unquoted reserved word is being used.

Statement terminators and case

  • Interactive clients typically terminate statements with ;.

  • Keywords are case-insensitive. Identifier case behavior is controlled by system variables such as lower_case_table_names. See System Variables. A common default is case-insensitive table names, with a value of 1.