SQL Command Syntax

SingleStore supports basic SQL elements, including:

  • Arrays

  • Comments

  • Delimiter

  • Identifiers

  • Operators

  • Parameters

  • Strings

  • Variables

Arrays

Arrays consist of an ordered set of elements, where each element in the array must have the same data type. For example, you cannot have integer and string elements in the same array. Refer to ARRAY for more information.

Example

Acceptable formats:

sample_int ARRAY(INT) = [1,2,3,4];
sample_varchar ARRAY(VARCHAR(25)) = ["apples", "oranges", "bananas"];

Unacceptable formats:

sample_int ARRAY(VARCHAR(10)) = [1,"apple",2, "oranges", 3,"bananas"];

Comments

SingleStore supports the following comment types:

  • Single line comments: Add -- at the start of any line to add single line comments in your code. For example,

    -- this is a comment
    -- **This is also a comment --
  • Multi-line or block comments: To specify multi-line or block comments, enclose the comment in /* <comment> */. For example,

    /* This comment
    can span
    multiple lines. */

Delimiter

By default, SingleStore uses a ; (semicolon) as the statement delimiter. You can modify the delimiter using the DELIMITER command. For example,

DELIMITER //

Refer to MySQL Client Delimiters for more information.

Identifiers

Identifiers are the names given by a database creator or user to database objects. Some examples are tables, columns, indexes, views, aliases, and other objects.

Identifiers can start with capital or lowercase letters, a dollar sign, or a combination of letters and numbers. Identifiers cannot have a solely numeric name. The use of decimals, symbols, and all numeric names requires back tics.

Examples

Acceptable formats:

CREATE TABLE Assets_104;
CREATE TABLE 104_Assets;
CREATE TABLE Assets$104;
CREATE TABLE `1.04_assets`;
CREATE TABLE `99999_assets`;
CREATE TABLE `#@*_assets`;
CREATE TABLE `*&%$@`;

Unacceptable formats:

CREATE TABLE 104;
CREATE TABLE 1.04_assets;
CREATE TABLE assets_1.04;

Operators

Operators are either a reserved character or word used mainly with the WHERE clause to perform comparative operations. SingleStore uses most of the standard mathematic, bit, and comparison operators. Here are some operators that SingleStore supports:

Operator Type

Supported Operators

Arithmetic

+, -, *, /, %

Assignment

=, :=

Bitwise

&, |, ^, ~, <<, >>

Comparison

=, <=>, >, >=, <, <=, !=

BETWEEN ... AND ..., NOT BETWEEN ... AND ...

IN(), NOT IN(), IS, IS NOT, IS NULL, IS NOT NULL, ISNULL(), LIKE, NOT LIKE, strcmp()

Refer to Comparison Operators for more information.

JSON

::, ::$, ::%

Logical

AND, OR, NOT

&&, ||, !

Typecast

:>, !:>

Refer to Cast Operators for more information.

Parameters

A parameter is used to exchange data among stored procedures and functions. Refer to CREATE FUNCTION (UDF) for more information.

Examples

CREATE FUNCTION num_parameter(emp_id INT);

Strings

A string is a data type that is used to store data in a table. Strings are enclosed by single or double quotes. SingleStore supports a variety of String Functions.

Examples

Basic string function format is shown below:

SELECT 'exp_str\3 exp_1';
SELECT "exp_str\3 exp_1";

Variables

A variable is an object that can be a single data value or a specific type (i.e., date, integer, etc.). Variables can start with capital or lowercase letters, a dollar sign, or a combination of letters and numbers. Variables cannot have a solely numeric name. The use of decimals, symbols, and all numeric names requires back tics.

Examples

Acceptable formats:

SET @str = CAST(123 AS CHAR(5));
SET @var = 0;
SET @$Some7_var = 0;
SET @`29999` = 1010;

Unacceptable formats:

SET @'var_name' =1010;
SET @"var_name" = 1010;
SET @29999 = 1010;

Last modified: August 2, 2023

Was this article helpful?