Fork me on GitHub

SqlBuilder Supported SQL Reference

The reference below attempts to enumerate most of the SQL syntax supported by SqlBuilder, although it is not exhaustive.

General Notes

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.

Most constructors which take an enum value have a named static method for constructing the object with each enum value.

Queries

DDL Queries

CreateTableQuery
  1. CREATE TABLE <tableName> (<column> [ <columnConstraint> ], ...)
  2. [ TABLESPACE <tableSpace> ]
CreateIndexQuery [1]
  1. CREATE INDEX <indexName> ON <table> (<column>, ...)
  2. [ TABLESPACE <tableSpace> ]
CreateViewQuery
  1. CREATE VIEW [ <viewName> (<column>, ...) ]
  2. AS <selectQuery>
  3. [ WITH CHECK OPTION ]
AlterTableQuery
  1. ALTER TABLE <table> <action>
DropQuery
  1. DROP <objType> <objName> [ <behavior> ]
GrantQuery
  1. GRANT <privilege>, ... ON <target> TO <grantee>, ... [ WITH GRANT OPTION ]
RevokeQuery
  1. REVOKE <privilege>, ... ON <target> FROM <grantee>, ... [ <behavior> ]

DML Queries

SelectQuery
  1. SELECT [ DISTINCT ] <column>, ...
  2. FROM [ <join>, ... ] | [ <table>, ... ]
  3. [ WHERE <condition> ]
  4. [ GROUP BY <group>, ...
  5. [ HAVING <havingCondition> ] ]
  6. [ ORDER BY <ordering> [ <orderingDir> ], ... ]
  7. [ FOR UPDATE ]
InsertQuery
  1. INSERT INTO <table> ( <column>, ... ) VALUES ( <value>, ... )
InsertSelectQuery
  1. INSERT INTO <table> ( <column>, ... ) <selectQuery>
DeleteQuery
  1. DELETE FROM <table>
  2. [ WHERE <condition> ]
UnionQuery
  1. <selectQuery> UNION [ ALL ] <selectQuery> ...
  2. [ ORDER BY <ordering> [ <orderingDir> ], ... ]
UpdateQuery
  1. UPDATE <table> SET <column> = <value>, ...
  2. [ WHERE <condition> ]
Subquery
  1. ( <subQuery> )

Clauses

Conditions

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
  1. ( <subCondition> [ <comboOp> <subCondition> ... ] )
UnaryCondition
  1. ( <unaryOp> <value> )
BinaryCondition
  1. ( <value1> <binaryOp> <value2>)
InCondition
  1. ( <column> [ NOT ] IN ( <value> , ... ) )
NotCondition
  1. ( NOT <subCondition> )
CustomCondition
  1. ( <customCondition> )

Expressions

Expression objects represent value clauses. All expressions have similar logic to Conditions for handling empty content.

ComboExpression
  1. ( <subExpression> [ <comboOp> <subExpression> ... ] )
NegateExpression
  1. ( - <subExpression> )
CustomExpression
  1. ( <customExpression> )

Simple Values

ValueObject
  1. '<value>'
NumberValueObject
  1. <number>

Complex Values

SimpleCaseStatement
  1. ( CASE <column>
  2. WHEN <value> THEN <result>
  3. [ WHEN <value> THEN <result> ... ]
  4. [ ELSE <elseResult> ]
  5. END )
CaseStatement
  1. ( CASE
  2. WHEN <condition> THEN <result>
  3. [ WHEN <condition> THEN <result> ... ]
  4. [ ELSE <elseResult> ]
  5. END )
FunctionCall
  1. <functionName>( [ DISTINCT ] [ <parameter>, ... ] )
Comment
  1. -- <myCommentHere>\n
AliasedObject
  1. <obj> AS <alias>
CustomSql
  1. <customSql>

[1]
This syntax is not ANSI SQL92 compliant.