# 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](https://docs.singlestore.com/db/v9.1/reference/sql-reference/procedural-sql-reference/array.md) for more information.

## Example

Acceptable formats:

```sql
sample_int ARRAY(INT) = [1,2,3,4];

sample_varchar ARRAY(VARCHAR(25)) = ["apples", "oranges", "bananas"];
```

Unacceptable formats:

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

```

## Comments

SingleStore supports the following comment types:

* **Single line comments**: Add `--` or `#` at the start of any line to add single line comments in your code. For example,
  ```sql
  -- this is a comment
  # 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,
  ```sql
  /* 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,

```sql
DELIMITER //
```

Refer to [MySQL Client Delimiters](https://docs.singlestore.com/db/v9.1/reference/sql-reference/procedural-sql-reference/mysql-client-delimiters.md) 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:

```sql
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:

```sql
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        | `+`,`-`,`*`,`/`,`%`**Note**:SingleStorereturns`NULL`when dividing by zero. To return an error,SingleStorerecommends using a stored procedure with error/exception handling. Refer to[Exceptions and Exception Handling](https://docs.singlestore.com/db/v9.1/reference/sql-reference/procedural-sql-reference/exceptions-and-exception-handling.md)for more information. |
| 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](https://docs.singlestore.com/db/v9.1/reference/sql-reference/comparison-operators-and-functions.md)for more information.                                    |
| JSON              | `::`,`::$`,`::%`                                                                                                                                                                                                                                                                                                                                                         |
| Logical           | `AND`,`OR`,`NOT``&&`,`\|\|`,`!`                                                                                                                                                                                                                                                                                                                                          |
| Typecast          | `:>`,`!:>`Refer to[Cast Operators](https://docs.singlestore.com/db/v9.1/reference/sql-reference/conditional-functions/cast-or-convert/#UUID-cc2c6e3c-477b-ad9f-074b-545f479017c1.md)for more information.                                                                                                                                                                |

## Parameters

A parameter is used to exchange data among stored procedures and functions. Refer to [CREATE FUNCTION (UDF)](https://docs.singlestore.com/db/v9.1/reference/sql-reference/procedural-sql-reference/create-function-udf.md) for more information.

## Examples

```sql
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](https://docs.singlestore.com/db/v9.1/reference/sql-reference/string-functions.md).

## Examples

Basic string function format is shown below:

```sql
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:

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

Unacceptable formats:

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

***

Modified at: April 24, 2025

Source: [/db/v9.1/reference/sql-reference/sql-command-syntax/](https://docs.singlestore.com/db/v9.1/reference/sql-reference/sql-command-syntax/)

(An index of the documentation is available at /llms.txt)
