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
  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> ]

DML Queries

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> )

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

Expressions

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

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

Simple Values

ValueObject
  '<value>'
NumberValueObject
  <number>

Complex Values

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>

[1]
This syntax is not ANSI SQL92 compliant.