GridGain Developers Hub

Grammar Reference

This section describes grammar elements that are common to multiple SQL functions (DDL, Distribution Zones, etc.).

column_definition_or_list

Diagram( Choice(0, Sequence( Choice(0, Sequence( Choice(0,Sequence( NonTerminal('column_name'), NonTerminal('data_type')) )), Sequence( Terminal('('), OneOrMore(Sequence( NonTerminal('column_name'), NonTerminal('data_type')), Terminal(',') ),Terminal(')') )))))

Keywords and parameters:

  • column_name - a column name.

  • data_type - a valid data type.

Referenced by:


column_name_or_list

Diagram( Choice(0, Sequence( Choice(0, Sequence( Choice(0,Sequence( NonTerminal('column_name')) )), Sequence( Terminal('('), OneOrMore(Sequence( NonTerminal('column_name')), Terminal(',') ),Terminal(')') )))))

Keywords and parameters:

  • column_name - a column name.

Referenced by:


sorted_column_list

Diagram( Sequence('(', OneOrMore(Sequence(NonTerminal('column_name'), Optional(Choice(0, Terminal('ASC'), Terminal('DESC')))), ','), ')') )

Keywords and parameters:

  • column_name - a column name.

Referenced by:


constraint

Diagram(Sequence( Optional(Sequence(Terminal('CONSTRAINT'),NonTerminal('constraint_name') )), Terminal('PRIMARY KEY'), Optional( Choice(0, Sequence( Terminal('USING'), Choice (0, Sequence(Terminal('SORTED'), NonTerminal('sorted_column_list', {href:'./grammar-reference/#sorted_column_list'}) ), Sequence('HASH', NonTerminal('column_list', {href:'./grammar-reference/#column_list'}))) )) )))

Keywords and parameters:

  • constraint_name - a name of the constraint.

Referenced by:


qualified_table_name

Diagram(Sequence( Optional(Sequence(NonTerminal('schema'),NonTerminal('.') ),), NonTerminal('table_name') ), )

Keywords and parameters:

  • schema - a name of the table schema.

  • table_name - a name of the table.

Referenced by:


column_definition

Diagram( Sequence( NonTerminal('column_name'), NonTerminal('DATA TYPE', {href:'./data-types'}), Optional(Sequence(Optional('NOT'),Terminal('NULL'))) ), End({type:'complex'}) )

Diagram( Start({type:'complex'}), Sequence( Optional(Sequence(Terminal('DEFAULT'), Choice(1,NonTerminal('identifier'), NonTerminal('literal_value'), Sequence(Terminal('CURRENT TIMESTAMP'), Optional(Sequence(Terminal('+'),Terminal('INTERVAL'), NonTerminal('interval'))) ) ),)), Optional(Terminal('PRIMARY KEY')), ))

Keywords and parameters:

  • column_name - a column name.

  • DATA TYPE - the data type allowed in the column.

  • identifier - the random identifier for the row. Can be generated by using the rand_uuid function.

  • literal_value - a value to be assigned as default.

  • CURRENT TIMESTAMP - the function that returns current time. Can only be used for TIMESTAMP columns.

  • interval - the time interval by which the timestamp should be offset.

Referenced by:


parameter

Diagram( NonTerminal('parameter_name'), Terminal('='), NonTerminal('parameter_value'))

Parameters:

  • parameter_name - the name of the parameter.

  • parameter_value - the value of the parameter.

When a parameter is specified, you can provide it as a literal value or as an identifier. For example:

CREATE ZONE test_zone;
CREATE TABLE test_table (id INT PRIMARY KEY, val INT) WITH PRIMARY_ZONE=test_zone;

In this case, test_zone is the identifier, and is used as an identifier. When used like this, the parameters are not case-sensitive.

CREATE ZONE "test_zone";
CREATE TABLE test_table (id INT PRIMARY KEY, val INT) WITH PRIMARY_ZONE='test_zone';

In this case, test_zone is created as a literal value, and is used as a literal. When used like this, the parameter is case-sensitive.

CREATE ZONE test_zone;
CREATE TABLE test_table (id INT PRIMARY KEY, val INT) WITH PRIMARY_ZONE=`TEST_ZONE`;

In this case, test_zone is created as an identifier, and is case-insensitive. As such, when TEST_ZONE is used as a literal, it still matches the identifier.

Referenced by:


System Functions

rand_uuid

This function generates a random UUID value each time it is called.

Example:

CREATE TABLE t (id uuid default rand_uuid primary key, val int)

Referenced by: