The reference below attempts to enumerate most of the SQL syntax supported by SqlBuilder, although it is not exhaustive.
Almost every method has a "custom" variation which supports inserting more complicated objects in place of the more common ones. The custom variation will often handle a range of Object types automatically.
Example Common Method | Equivalent Custom Method |
---|---|
SelectQuery.addColumns(Column...) |
SelectQuery.addCustomColumns(Object...) |
Most constructors which take an enum value have a named static method for constructing the object with each enum value.
Example Constructor With Enum | Equivalent Static Method |
---|---|
new ComboCondition(Op.AND) |
ComboCondition.and() |
CreateTableQuery |
CREATE TABLE <tableName> (<column> [ <columnConstraint> ], ...) [ TABLESPACE <tableSpace> ] |
CreateIndexQuery [1] |
CREATE INDEX <indexName> ON <table> (<column>, ...) [ TABLESPACE <tableSpace> ] |
CreateViewQuery
|
CREATE VIEW [ <viewName> (<column>, ...) ] AS <selectQuery> [ WITH CHECK OPTION ] |
AlterTableQuery |
ALTER TABLE <table> <action> |
DropQuery |
DROP <objType> <objName> [ <behavior> ] |
GrantQuery |
GRANT <privilege>, ... ON <target> TO <grantee>, ... [ WITH GRANT OPTION ] |
RevokeQuery |
REVOKE <privilege>, ... ON <target> FROM <grantee>, ... [ <behavior> ] |
SelectQuery
|
SELECT [ DISTINCT ] <column>, ... FROM [ <join>, ... ] | [ <table>, ... ] [ WHERE <condition> ] [ GROUP BY <group>, ... [ HAVING <havingCondition> ] ] [ ORDER BY <ordering> [ <orderingDir> ], ... ] [ FOR UPDATE ] |
InsertQuery |
INSERT INTO <table> ( <column>, ... ) VALUES ( <value>, ... ) |
InsertSelectQuery
|
INSERT INTO <table> ( <column>, ... ) <selectQuery> |
DeleteQuery
|
DELETE FROM <table> [ WHERE <condition> ] |
UnionQuery
|
<selectQuery> UNION [ ALL ] <selectQuery> ... [ ORDER BY <ordering> [ <orderingDir> ], ... ] |
UpdateQuery
|
UPDATE <table> SET <column> = <value>, ... [ WHERE <condition> ] |
Subquery
|
( <subQuery> ) |
Condition objects represent boolean clauses. All conditions have logic for determining whether or not they actually contain any content and will not write anything to the generated query if they consider themselves empty.
ComboCondition |
( <subCondition> [ <comboOp> <subCondition> ... ] ) |
UnaryCondition |
( <unaryOp> <value> ) |
BinaryCondition |
( <value1> <binaryOp> <value2>) |
InCondition |
( <column> [ NOT ] IN ( <value> , ... ) ) |
NotCondition |
( NOT <subCondition> ) |
CustomCondition |
( <customCondition> ) |
Expression objects represent value clauses. All expressions have similar logic to Conditions for handling empty content.
ComboExpression |
( <subExpression> [ <comboOp> <subExpression> ... ] ) |
NegateExpression |
( - <subExpression> ) |
CustomExpression |
( <customExpression> ) |
ValueObject |
'<value>' |
NumberValueObject |
<number> |
SimpleCaseStatement |
( CASE <column> WHEN <value> THEN <result> [ WHEN <value> THEN <result> ... ] [ ELSE <elseResult> ] END ) |
CaseStatement |
( CASE WHEN <condition> THEN <result> [ WHEN <condition> THEN <result> ... ] [ ELSE <elseResult> ] END ) |
FunctionCall
|
<functionName>( [ DISTINCT ] [ <parameter>, ... ] ) |
Comment |
-- <myCommentHere>\n |
AliasedObject |
<obj> AS <alias> |
CustomSql |
<customSql> |
JdbcEscape |
{ <escapeType> <sql> } |
JdbcScalarFunction
|
{ fn <funcCall> } |