/  Yamcs Server Manual  /  SQL Language  /  Statements

Statements

ALTER SEQUENCE Statement

alterSequenceStatement ::=  "ALTER" "SEQUENCE" objectName "RESTART" [ "WITH" restart ]
restart                ::=  integer

Changes the properties of an existing sequence generator.

ALTER TABLE Statement

alterTableStatement ::=  "ALTER" "TABLE" objectName "RENAME" "TO" objectName

Changes table properties. Currently this is limited to renaming.

CLOSE STREAM Statement

closeStreamStatement ::=  "CLOSE" "STREAM" objectName

CREATE TABLE Statement

createTableStatement  ::=  "CREATE" "TABLE" [ "IF" "NOT" "EXISTS" ] tableName "("
                               tableColumnDefinition ( "," tableColumnDefinition )*
                               "," "PRIMARY" "KEY" "(" columnName ( "," columnName )* ")"
                               [ "," "INDEX" "(" columnName ( "," columnName )* ")" ]
                           ")"
                           [ "HISTOGRAM" "(" columnName ( "," columnName )* ")" ]
                           [ "ENGINE" engineName ]
                           [ "PARTITION" "BY" partitioningSpec ]
                           [ "TABLESPACE" tablespaceName ]
                           [ "TABLE_FORMAT" "=" "COMPRESSED" ]
tableColumnDefinition ::=  columnName dataType [ "AUTO_INCREMENT" ]
dataType              ::=  simpleDataType | arrayDataType
arrayDataType         ::=  simpleDataType "[]"
simpleDataType        ::=  : "BINARY"
                           | "BOOLEAN"
                           | "BYTE"
                           | "DOUBLE"
                           | "ENUM"
                           | "HRES_TIMESTAMP"
                           | "INT"
                           | "LONG"
                           | "PARAMETER_VALUE"
                           | "SHORT"
                           | "STRING"
                           | "PROTOBUF" "(" className ")"
                           | "TIMESTAMP"
                           | "UUID"
partitioningSpec      ::=  "TIME" "(" columnName [ "(" timePartitioning ")" ] ")"
                           | "VALUE" "(" columnName ")"
                           | "TIME_AND_VALUE" "("
                                 columnName [ "(" timePartitioning ")" ],
                                 columnName
                             ")"
className             ::=  string
columnName            ::=  objectName
timePartitioning      ::=  "'YYYY'" | "'YYYY/DOY'" | "'YYYY/MM'"

Partitioning

Partitioning allows to separate the data in different RocksDB databases (by time) and column families (by value).

Time partitioning allows the following schemes:

  • YYYY: one RocksDB database per year.

  • YYYY/DOY: one RocksDB database per combination year, and day of the year.

  • YYYY/MM: one RocksDB database per combination year, and month of the year.

Partitioning by time ensures that old data is frozen and not disturbed by new data coming in.

CREATE STREAM Statement

createStreamStatement  ::=  "CREATE" "STREAM" streamName (
                                "AS" streamExpression [ "NOFOLLOW" ]
                                | "(" streamColumnDefinition ( "," streamColumnDefinition )* ")"
                             )
streamExpression       ::=  selectExpression | mergeExpression
streamColumnDefinition ::=  columnName dataType

DELETE Statement

deleteStatement ::=  "DELETE" "FROM" objectName
                     [ "WHERE" expression ]
                     [ "LIMIT" integer ]

Delete records from a table.

DESCRIBE Statement

describeStatement ::=  "DESCRIBE" objectName

Obtain information about table or stream structure.

DROP TABLE Statement

dropTableStatement ::=  "DROP" "TABLE" [ "IF" "EXISTS" ] objectName

Remove a table.

INSERT Statement

insertStatement ::=  ( "INSERT" | "UPSERT" | "INSERT_APPEND" | "UPSERT_APPEND" | "LOAD" )
                     "INTO" objectName
                     (streamExpression | insertValues)
insertValues    ::=  "(" columnName ( "," columnName )* "VALUES" "(" selectList ")"

SELECT TABLE Statement

selectTableStatement ::=  "SELECT" selectList
                          "FROM" tupleSourceExpression
                          [ "[" windowSpecification "]" ]
                          [ "WHERE" expression ]
                          [ "ORDER" [ "ASC" | "DESC" ] ]
                          [ "LIMIT" [ offset "," ] rowCount ]

SHOW DATABASES Statement

showDatabasesStatement ::=  "SHOW" "DATABASES"

Lists the databases.

SHOW ENGINES Statement

showEnginesStatement ::=  "SHOW" "ENGINES"

Lists the server's storage engines.

SHOW SEQUENCES Statement

showSequencesStatement ::=  "SHOW" "SEQUENCES"

Lists the sequences in the current database.

SHOW STREAMS Statement

showStreamsStatement ::=  "SHOW" "STREAMS"

Lists the streams in the current database.

SHOW TABLES Statement

showTablesStatement ::=  "SHOW" "TABLES"

Lists the tables in the current database.

UPDATE Statement

updateStatement ::=  "UPDATE" "SET" columnName "=" expression
                     ( "," columnName "=" expression )*
                     [ "WHERE" expression ]
                     [ "LIMIT" integer ]