This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

Reference

Complete documentation about Genji’s SQL syntax

1 - ALTER TABLE

Manage tables and table constraints

Synopsis

ALTER TABLE statement

ALTERTABLEtable-nameRENAMETOnew-table-nameADDFIELDfield-definition

Field definition

Field constraint

PRIMARYKEYUNIQUENOTNULLDEFAULT(expr)expr

2 - CREATE INDEX

Define a new index

Synopsis

CREATE INDEX statement

CREATEUNIQUEINDEXindex-nameIFNOTEXISTSindex-nameONtable-name(field-path,)

3 - CREATE SEQUENCE

Define a new sequence

Synopsis

CREATE SEQUENCE statement

CREATESEQUENCEIFNOTEXISTSsequence-nameAStype-nameINCREMENTBYintegerNOMINVALUEMAXVALUECYCLEMINVALUEintegerMAXVALUEintegerSTARTWITHintegerCACHEintegerCYCLEtake one or more branches, once each, in any order1+

4 - Transactions

Manage transactions

Synopsis

BEGIN TRANSACTION statement

BEGINTRANSACTIONREADONLYREADWRITE

ROLLBACK TRANSACTION statement

ROLLBACKTRANSACTION

COMMIT TRANSACTION statement

COMMITTRANSACTION

5 - CREATE TABLE

Define a new table

Synopsis

CREATE TABLE statement

Parameters

IF NOT EXISTS

Do not throw an error if a table with the same name already exists.

table-name

The name of the table to be created.

Field definition

table-name

The name of the table to be created.

Field constraint

PRIMARYKEYUNIQUENOTNULLDEFAULT(expr)exprCHECK(expr)

Table constraint

PRIMARYKEY(field-path)UNIQUEKEY(field-path)CHECK(expr)

6 - DELETE

Delete documents

Synopsis

DELETE statement

DELETEFROMtable-nameWHEREexprORDERBYexprASCDESCLIMITexprOFFSETexpr

7 - DROP INDEX

Delete an index and all of its content

Synopsis

DROP INDEX statement

DROPINDEXIFEXISTSindex-name

8 - DROP SEQUENCE

Delete a sequence

Synopsis

DROP SEQUENCE statement

DROPSEQUENCEIFEXISTSsequence-name

9 - DROP TABLE

Delete a table and all of its content

Synopsis

DROP TABLE statement

DROPTABLEIFEXISTStable-name

10 - EXPLAIN

Generate query plan

Synopsis

EXPLAIN statement

11 - INSERT

Insert documents

Synopsis

INSERT statement

VALUES clause

(field-name,)VALUES(expr,),VALUESdocument-literal,

Conflict clause

ONCONFLICTIGNOREREPLACEDONOTHINGDOREPLACE

RETURNING clause

RETURNINGexprASalias

12 - REINDEX

Reindex tables, indexes or everything

Synopsis

REINDEX statement

REINDEXtable-nameindex-name

13 - SELECT

Query the database

Synopsis

SELECT statement

SELECTDISTINCTresult-field,FROMtable-nameWHEREexprGROUPBYexprselect-coreUNIONUNIONALLORDERBYexprASCDESCLIMITexprOFFSETexpr

Result field

exprASfield-alias*

14 - UPDATE

Update documents

Synopsis

UPDATE statement

UPDATEtable-nameSETfield-path=expr,UNSETtop-level-field,WHEREexpr