SQL Command Syntax
On this page
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.
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 commentcan spanmultiple lines. */
Delimiter
By default, SingleStore uses a ;
(semicolon) as the statement delimiter.DELIMITER
command.
DELIMITER //
Refer to MySQL Client Delimiters for more information.
Identifiers
Identifiers are the names given by a database creator or user to database objects.
Identifiers can start with capital or lowercase letters, a dollar sign, or a combination of letters and numbers.
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.
Operator Type |
Supported Operators |
---|---|
Arithmetic |
|
Assignment |
|
Bitwise |
|
Comparison |
Refer to Comparison Operators for more information. |
JSON |
|
Logical |
|
Typecast |
Refer to Cast Operators for more information. |
Parameters
A parameter is used to exchange data among stored procedures and functions.
Examples
CREATE FUNCTION num_parameter(emp_id INT);
Strings
A string is a data type that is used to store data in a table.
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.
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