Grammar Reference
EBNF Grammar
Section titled “EBNF Grammar”Expression ::= SelectExpr | InsertExpr | UpdateExpr | DeleteExpr
SelectExpr ::= "select" "*" "from" Ident FilterOrWhere? OrderBy? Limit? | "select" Ident "{" ShapeFields "}" FilterOrWhere? OrderBy? Limit? | "select" Ident FilterOrWhere? OrderBy? Limit?
InsertExpr ::= "insert" Ident "{" Assignments "}"
UpdateExpr ::= "update" Ident FilterClause? "set" "{" Assignments "}"
DeleteExpr ::= "delete" Ident FilterClause?
FilterOrWhere ::= "filter" Condition | "where" Condition
OrderBy ::= "order" "by" Ident ("asc" | "desc")?
Limit ::= "limit" Number
ShapeFields ::= ShapeField ("," ShapeField)*
ShapeField ::= Ident | Ident ":" "{" ShapeFields "}"
Assignments ::= Assignment ("," Assignment)*
Assignment ::= Ident ":=" Literal
Condition ::= TermCondition (BinaryOp TermCondition)*
TermCondition ::= Literal | Ident | "(" Condition ")"
BinaryOp ::= "=" | "!=" | ">" | ">=" | "<" | "<="
Literal ::= Number | "true" | "false" | String
Number ::= [0-9]+
Ident ::= [a-zA-Z_][a-zA-Z0-9_]*
String ::= '"' [^"]* '"'Keywords
Section titled “Keywords”The following are reserved keywords in BQL:
| Keyword | Usage |
|---|---|
select | Query data |
insert | Add new records |
update | Modify existing records |
delete | Remove records |
filter | Add conditions (BQL style) |
where | Add conditions (SQL style) |
set | Specify update values |
order | Sort results |
by | Used with order |
asc | Ascending order |
desc | Descending order |
limit | Limit result count |
from | Specify table (with *) |
true | Boolean literal |
false | Boolean literal |
Syntax Notes
Section titled “Syntax Notes”Shape Syntax { }
Section titled “Shape Syntax { }”Used to specify which fields to select or what values to set:
-- SELECT: fields to returnselect User { id, name, email }
-- INSERT: field assignmentsinsert User { name := "Alice", email := "a@b.com" }
-- UPDATE: fields to modifyupdate User filter id = 1 set { name := "Bob" }Assignment Operator :=
Section titled “Assignment Operator :=”Used in INSERT and UPDATE to assign values:
name := "Alice"count := 42active := trueFilter vs Where
Section titled “Filter vs Where”Both work identically - filter is BQL style, where is SQL style:
-- These are equivalentselect User { name } filter id = 1select User { name } where id = 1