-
- All Superinterfaces:
Attachable,AutoCloseable,ConditionProvider,FieldLike,Flow.Publisher<R>,Iterable<R>,org.reactivestreams.Publisher<R>,Query,QueryPart,ResultQuery<R>,Select<R>,Serializable,Statement,TableLike<R>
public interface SelectQuery<R extends Record> extends Select<R>, ConditionProvider
ASELECTstatement (model API).This type is the model API representation of a
Selectstatement, which can be mutated after creation. The advantage of this API compared to the DSL API is a more simple approach to writing dynamic SQL.Instances can be created using
DSLContext.selectQuery()and overloads.- Author:
- Lukas Eder
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description voidaddConditions(Collection<? extends Condition> conditions)Adds new conditions to the query, connecting them to existing conditions withOperator.AND.voidaddConditions(Condition condition)Adds a new condition to the query, connecting them to existing conditions withOperator.AND.voidaddConditions(Condition... conditions)Adds new conditions to the query, connecting them to existing conditions withOperator.AND.voidaddConditions(Operator operator, Collection<? extends Condition> conditions)Adds new conditions to the query, connecting them to existing conditions with the provided operator.voidaddConditions(Operator operator, Condition condition)Adds a new condition to the query, connecting them to existing conditions with the provided operator.voidaddConditions(Operator operator, Condition... conditions)Adds new conditions to the query, connecting them to existing conditions with the provided operator.voidaddConnectBy(Condition condition)Add an Oracle-specificCONNECT BYclause to the query.voidaddConnectByNoCycle(Condition condition)Add an Oracle-specificCONNECT BY NOCYCLEclause to the query.voidaddDistinctOn(Collection<? extends SelectFieldOrAsterisk> fields)Add a PostgreSQL-specificDISTINCT ON (fields...)clause.voidaddDistinctOn(SelectFieldOrAsterisk... fields)Add a PostgreSQL-specificDISTINCT ON (fields...)clause.voidaddFrom(Collection<? extends TableLike<?>> from)Add tables to the table product.voidaddFrom(TableLike<?> from)Add tables to the table product.voidaddFrom(TableLike<?>... from)Add tables to the table product.voidaddGroupBy(Collection<? extends GroupField> fields)Adds grouping fields.voidaddGroupBy(GroupField... fields)Adds grouping fields.voidaddHaving(Collection<? extends Condition> conditions)Adds new conditions to the having clause of the query, connecting them with each other withOperator.AND.voidaddHaving(Condition condition)Adds a new condition to the having clause of the query, connecting it with each other withOperator.AND.voidaddHaving(Condition... conditions)Adds new conditions to the having clause of the query, connecting them with each other withOperator.AND.voidaddHaving(Operator operator, Collection<? extends Condition> conditions)Adds new conditions to the having clause of query, connecting them with each other withoperator.voidaddHaving(Operator operator, Condition condition)Adds a new condition to the having clause of query, connecting it with each other withoperator.voidaddHaving(Operator operator, Condition... conditions)Adds new conditions to the having clause of query, connecting them with each other withoperator.voidaddHint(String hint)Add an Oracle-style hint to the select clause.voidaddJoin(TableLike<?> table, Condition condition)Joins the existing table product to a new table using a condition, connecting them with each other withOperator.AND.voidaddJoin(TableLike<?> table, Condition... conditions)Joins the existing table product to a new table using a condition, connecting them with each other withOperator.AND.voidaddJoin(TableLike<?> table, JoinType type, Condition condition)Joins the existing table product to a new table using a condition, connecting them with each other withOperator.AND.voidaddJoin(TableLike<?> table, JoinType type, Condition... conditions)Joins the existing table product to a new table using a condition, connecting them with each other withOperator.AND.voidaddJoin(TableLike<?> table, JoinType type, Condition[] conditions, Field<?>[] partitionBy)Joins the existing table product to a new table using conditions, connecting them with each other withOperator.AND.voidaddJoin(TableLike<?> table, JoinType type, Condition conditions, Field<?>[] partitionBy)Joins the existing table product to a new table using conditions, connecting them with each other withOperator.AND.voidaddJoinOnKey(TableLike<?> table, JoinType type)Joins the existing table product to a new table using a foreign key.voidaddJoinOnKey(TableLike<?> table, JoinType type, ForeignKey<?,?> key)Joins the existing table product to a new table using a foreign key.voidaddJoinOnKey(TableLike<?> table, JoinType type, TableField<?,?>... keyFields)Joins the existing table product to a new table using a foreign key.voidaddJoinUsing(TableLike<?> table, Collection<? extends Field<?>> fields)Joins the existing table product to a new table with aUSINGclause.voidaddJoinUsing(TableLike<?> table, JoinType type, Collection<? extends Field<?>> fields)Joins the existing table product to a new table with aUSINGclause.voidaddLimit(int numberOfRows)Limit the results of this select.voidaddLimit(int offset, int numberOfRows)Limit the results of this select.voidaddLimit(int offset, Param<Integer> numberOfRows)Limit the results of this select using named parameters.voidaddLimit(Number numberOfRows)Limit the results of this select.voidaddLimit(Number offset, Number numberOfRows)Limit the results of this select.voidaddLimit(Number offset, Param<? extends Number> numberOfRows)Limit the results of this select using named parameters.voidaddLimit(Param<? extends Number> numberOfRows)Limit the results of this select using named parameters.voidaddLimit(Param<? extends Number> offset, Number numberOfRows)Limit the results of this select.voidaddLimit(Param<? extends Number> offset, Param<? extends Number> numberOfRows)Limit the results of this select using named parameters.voidaddLimit(Param<Integer> offset, int numberOfRows)Limit the results of this select.voidaddOffset(int offset)Add anOFFSETclause to the query.voidaddOffset(Number offset)Add anOFFSETclause to the query.voidaddOffset(Param<? extends Number> offset)Add anOFFSETclause to the query using a named parameter.voidaddOption(String option)Add a SQL Server-style query hint to the select clause.voidaddOrderBy(int... fieldIndexes)Adds ordering fields.voidaddOrderBy(Collection<? extends OrderField<?>> fields)Adds ordering fields.voidaddOrderBy(OrderField<?>... fields)Adds ordering fields.voidaddQualify(Collection<? extends Condition> conditions)Adds new conditions to the qualify clause of the query, connecting them with each other withOperator.AND.voidaddQualify(Condition condition)Adds a new condition to the qualify clause of the query, connecting it with each other withOperator.AND.voidaddQualify(Condition... conditions)Adds new conditions to the qualify clause of the query, connecting them with each other withOperator.AND.voidaddQualify(Operator operator, Collection<? extends Condition> conditions)Adds new conditions to the qualify clause of query, connecting them with each other withoperator.voidaddQualify(Operator operator, Condition condition)Adds a new condition to the qualify clause of query, connecting it with each other withoperator.voidaddQualify(Operator operator, Condition... conditions)Adds new conditions to the qualify clause of query, connecting them with each other withoperator.voidaddSeekAfter(Collection<? extends Field<?>> fields)Adds seeking fields.voidaddSeekAfter(Field<?>... fields)Adds seeking fields.voidaddSeekBefore(Collection<? extends Field<?>> fields)Deprecated.- [#7461] - SEEK BEFORE is not implemented correctlyvoidaddSeekBefore(Field<?>... fields)Deprecated.- [#7461] - SEEK BEFORE is not implemented correctlyvoidaddSelect(Collection<? extends SelectFieldOrAsterisk> fields)Add a list of select fields.voidaddSelect(SelectFieldOrAsterisk... fields)Add a list of select fields.voidaddWindow(Collection<? extends WindowDefinition> definitions)Adds new window definitions to the window clause of the query.voidaddWindow(WindowDefinition... definitions)Adds new window definitions to the window clause of the query.voidsetConnectByStartWith(Condition condition)Add an Oracle-specificSTART WITHclause to the query'sCONNECT BYclause.voidsetDistinct(boolean distinct)Add "distinct" keyword to the select clause.voidsetForKeyShare(boolean forKeyShare)Sets the "FOR KEY SHARE" flag onto the query.voidsetForNoKeyUpdate(boolean forNoKeyUpdate)Sets the "FOR NO KEY UPDATE" flag onto the query.voidsetForShare(boolean forShare)Sets the "FOR SHARE" flag onto the query.voidsetForUpdate(boolean forUpdate)Sets the "FOR UPDATE" flag onto the query.voidsetForUpdateNoWait()Some RDBMS allow for specifying the locking mode for the appliedFOR UPDATEclause.voidsetForUpdateOf(Collection<? extends Field<?>> fields)Some RDBMS allow for specifying the fields that should be locked by theFOR UPDATEclause, instead of the full row.voidsetForUpdateOf(Field<?>... fields)Some RDBMS allow for specifying the fields that should be locked by theFOR UPDATEclause, instead of the full row.voidsetForUpdateOf(Table<?>... tables)Some RDBMS allow for specifying the tables that should be locked by theFOR UPDATEclause, instead of the full row.voidsetForUpdateSkipLocked()Some RDBMS allow for specifying the locking mode for the appliedFOR UPDATEclause.voidsetForUpdateWait(int seconds)Some RDBMS allow for specifying the locking mode for the appliedFOR UPDATEclause.voidsetInto(Table<?> table)AddINTOclause to theSELECTstatement.voidsetLimitPercent(boolean percent)Add thePERCENTclause to aLIMITclause.voidsetOrderBySiblings(boolean orderBySiblings)Indicate whether theSIBLINGSkeyword should be used in anORDER BYclause to form anORDER SIBLINGS BYclause.voidsetWithCheckOption()Add aWITH CHECK OPTIONclause to the end of the subquery.voidsetWithReadOnly()Add aWITH READ ONLYclause to the end of the subquery.voidsetWithTies(boolean withTies)Add theWITH TIESclause to aLIMITclause.-
Methods inherited from interface org.jooq.Attachable
attach, configuration, detach
-
Methods inherited from interface java.util.concurrent.Flow.Publisher
subscribe
-
Methods inherited from interface org.jooq.Query
cancel, close, execute, executeAsync, executeAsync, getBindValues, getParam, getParams, getSQL, getSQL, getSQL, isExecutable
-
Methods inherited from interface org.jooq.ResultQuery
bind, bind, coerce, coerce, coerce, coerce, coerce, coerce, coerce, coerce, coerce, coerce, coerce, coerce, coerce, coerce, coerce, coerce, coerce, coerce, coerce, coerce, coerce, coerce, coerce, coerce, coerce, collect, fetch, fetch, fetch, fetch, fetch, fetch, fetch, fetch, fetch, fetch, fetch, fetch, fetch, fetch, fetchAny, fetchAny, fetchAny, fetchAny, fetchAny, fetchAny, fetchAny, fetchAny, fetchAny, fetchAny, fetchAny, fetchAny, fetchAny, fetchAny, fetchAnyArray, fetchAnyInto, fetchAnyInto, fetchAnyMap, fetchArray, fetchArray, fetchArray, fetchArray, fetchArray, fetchArray, fetchArray, fetchArray, fetchArray, fetchArray, fetchArray, fetchArray, fetchArray, fetchArrays, fetchAsync, fetchAsync, fetchGroups, fetchGroups, fetchGroups, fetchGroups, fetchGroups, fetchGroups, fetchGroups, fetchGroups, fetchGroups, fetchGroups, fetchGroups, fetchGroups, fetchGroups, fetchGroups, fetchGroups, fetchGroups, fetchGroups, fetchGroups, fetchGroups, fetchGroups, fetchGroups, fetchGroups, fetchGroups, fetchGroups, fetchGroups, fetchGroups, fetchGroups, fetchGroups, fetchGroups, fetchGroups, fetchGroups, fetchGroups, fetchGroups, fetchGroups, fetchGroups, fetchGroups, fetchGroups, fetchGroups, fetchGroups, fetchGroups, fetchGroups, fetchGroups, fetchInto, fetchInto, fetchInto, fetchLater, fetchLater, fetchLazy, fetchLazy, fetchMany, fetchMap, fetchMap, fetchMap, fetchMap, fetchMap, fetchMap, fetchMap, fetchMap, fetchMap, fetchMap, fetchMap, fetchMap, fetchMap, fetchMap, fetchMap, fetchMap, fetchMap, fetchMap, fetchMap, fetchMap, fetchMap, fetchMap, fetchMap, fetchMap, fetchMap, fetchMap, fetchMap, fetchMap, fetchMap, fetchMap, fetchMap, fetchMap, fetchMap, fetchMap, fetchMap, fetchMap, fetchMap, fetchMap, fetchMap, fetchMap, fetchMap, fetchMap, fetchMaps, fetchOne, fetchOne, fetchOne, fetchOne, fetchOne, fetchOne, fetchOne, fetchOne, fetchOne, fetchOne, fetchOne, fetchOne, fetchOne, fetchOne, fetchOneArray, fetchOneInto, fetchOneInto, fetchOneMap, fetchOptional, fetchOptional, fetchOptional, fetchOptional, fetchOptional, fetchOptional, fetchOptional, fetchOptional, fetchOptional, fetchOptional, fetchOptional, fetchOptional, fetchOptional, fetchOptional, fetchOptionalArray, fetchOptionalInto, fetchOptionalInto, fetchOptionalMap, fetchResultSet, fetchSet, fetchSet, fetchSet, fetchSet, fetchSet, fetchSet, fetchSet, fetchSet, fetchSet, fetchSet, fetchSet, fetchSet, fetchSet, fetchSingle, fetchSingle, fetchSingle, fetchSingle, fetchSingle, fetchSingle, fetchSingle, fetchSingle, fetchSingle, fetchSingle, fetchSingle, fetchSingle, fetchSingle, fetchSingle, fetchSingleArray, fetchSingleInto, fetchSingleInto, fetchSingleMap, fetchSize, fetchStream, fetchStreamInto, fetchStreamInto, forEach, getRecordType, getResult, intern, intern, intern, intern, iterator, keepStatement, maxRows, poolable, queryTimeout, resultSetConcurrency, resultSetHoldability, resultSetType, spliterator, stream
-
Methods inherited from interface org.jooq.Select
except, exceptAll, fetchCount, getSelect, intersect, intersectAll, union, unionAll
-
-
-
-
Method Detail
-
addSelect
@Support void addSelect(SelectFieldOrAsterisk... fields)
Add a list of select fields.- Parameters:
fields-
-
addSelect
@Support void addSelect(Collection<? extends SelectFieldOrAsterisk> fields)
Add a list of select fields.- Parameters:
fields-
-
setDistinct
@Support void setDistinct(boolean distinct)
Add "distinct" keyword to the select clause.
-
addDistinctOn
@Support({AURORA_POSTGRES,COCKROACHDB,H2,POSTGRES}) void addDistinctOn(SelectFieldOrAsterisk... fields)
Add a PostgreSQL-specificDISTINCT ON (fields...)clause.This also sets the
distinctflag totrue
-
addDistinctOn
@Support({AURORA_POSTGRES,COCKROACHDB,H2,POSTGRES}) void addDistinctOn(Collection<? extends SelectFieldOrAsterisk> fields)
Add a PostgreSQL-specificDISTINCT ON (fields...)clause.This also sets the
distinctflag totrue
-
setInto
@Support({ACCESS,ASE,AURORA_MYSQL,AURORA_POSTGRES,COCKROACHDB,CUBRID,DB2,DERBY,H2,HANA,HSQLDB,INFORMIX,INGRES,MARIADB,MEMSQL,MYSQL,ORACLE,POSTGRES,SQLDATAWAREHOUSE,SQLITE,SQLSERVER,TERADATA}) void setInto(Table<?> table)
AddINTOclause to theSELECTstatement.
-
addFrom
@Support void addFrom(TableLike<?> from)
Add tables to the table product.- Parameters:
from- The added tables
-
addFrom
@Support void addFrom(TableLike<?>... from)
Add tables to the table product.- Parameters:
from- The added tables
-
addFrom
@Support void addFrom(Collection<? extends TableLike<?>> from)
Add tables to the table product.- Parameters:
from- The added tables
-
addJoin
@Support void addJoin(TableLike<?> table, Condition condition)
Joins the existing table product to a new table using a condition, connecting them with each other withOperator.AND.- Parameters:
table- The joined tablecondition- The joining condition
-
addJoin
@Support void addJoin(TableLike<?> table, Condition... conditions)
Joins the existing table product to a new table using a condition, connecting them with each other withOperator.AND.- Parameters:
table- The joined tableconditions- The joining conditions
-
addJoin
@Support void addJoin(TableLike<?> table, JoinType type, Condition condition)
Joins the existing table product to a new table using a condition, connecting them with each other withOperator.AND.- Parameters:
table- The joined tabletype- The type of joincondition- The joining condition
-
addJoin
@Support void addJoin(TableLike<?> table, JoinType type, Condition... conditions)
Joins the existing table product to a new table using a condition, connecting them with each other withOperator.AND.- Parameters:
table- The joined tabletype- The type of joinconditions- The joining conditions
-
addJoin
@Support(ORACLE) @Pro void addJoin(TableLike<?> table, JoinType type, Condition conditions, Field<?>[] partitionBy)
Joins the existing table product to a new table using conditions, connecting them with each other withOperator.AND.This adds a
PARTITION BYclause to the right hand side of aOUTER JOINexpression.- Parameters:
table- The joined tabletype- The type of joinconditions- The joining conditionspartitionBy- ThePARTITION BYexpression- See Also:
TablePartitionByStep
-
addJoin
@Support(ORACLE) @Pro void addJoin(TableLike<?> table, JoinType type, Condition[] conditions, Field<?>[] partitionBy)
Joins the existing table product to a new table using conditions, connecting them with each other withOperator.AND.This adds a
PARTITION BYclause to the right hand side of aOUTER JOINexpression.- Parameters:
table- The joined tabletype- The type of joinconditions- The joining conditionspartitionBy- ThePARTITION BYexpression- See Also:
TablePartitionByStep
-
addJoinUsing
@Support void addJoinUsing(TableLike<?> table, Collection<? extends Field<?>> fields)
Joins the existing table product to a new table with aUSINGclause.If this is not supported by your RDBMS, then jOOQ will try to emulate this behaviour using the information provided in this query.
- Parameters:
table- The joined tablefields- The fields for theUSINGclause
-
addJoinUsing
@Support void addJoinUsing(TableLike<?> table, JoinType type, Collection<? extends Field<?>> fields)
Joins the existing table product to a new table with aUSINGclause.If this is not supported by your RDBMS, then jOOQ will try to emulate this behaviour using the information provided in this query.
- Parameters:
table- The joined tabletype- The type of joinfields- The fields for theUSINGclause
-
addJoinOnKey
@Support void addJoinOnKey(TableLike<?> table, JoinType type) throws DataAccessException
Joins the existing table product to a new table using a foreign key.- Parameters:
table- The joined tabletype- The type of join- Throws:
DataAccessException- If there is no non-ambiguous key definition known to jOOQ- See Also:
TableOnStep.onKey(ForeignKey)
-
addJoinOnKey
@Support void addJoinOnKey(TableLike<?> table, JoinType type, TableField<?,?>... keyFields) throws DataAccessException
Joins the existing table product to a new table using a foreign key.- Parameters:
table- The joined tabletype- The type of joinkeyFields- The foreign key fields- Throws:
DataAccessException- If there is no non-ambiguous key definition known to jOOQ- See Also:
TableOnStep.onKey(ForeignKey)
-
addJoinOnKey
@Support void addJoinOnKey(TableLike<?> table, JoinType type, ForeignKey<?,?> key)
Joins the existing table product to a new table using a foreign key.- Parameters:
table- The joined tabletype- The type of joinkey- The foreign key- See Also:
TableOnStep.onKey(ForeignKey)
-
addGroupBy
@Support void addGroupBy(GroupField... fields)
Adds grouping fields.Calling this with an empty argument list will result in an empty
GROUP BY ()clause being rendered.- Parameters:
fields- The grouping fields
-
addGroupBy
@Support void addGroupBy(Collection<? extends GroupField> fields)
Adds grouping fields.Calling this with an empty argument list will result in an empty
GROUP BY ()clause being rendered.- Parameters:
fields- The grouping fields
-
addHaving
@Support void addHaving(Condition condition)
Adds a new condition to the having clause of the query, connecting it with each other withOperator.AND.- Parameters:
condition- The condition
-
addHaving
@Support void addHaving(Condition... conditions)
Adds new conditions to the having clause of the query, connecting them with each other withOperator.AND.- Parameters:
conditions- The condition
-
addHaving
@Support void addHaving(Collection<? extends Condition> conditions)
Adds new conditions to the having clause of the query, connecting them with each other withOperator.AND.- Parameters:
conditions- The condition
-
addHaving
@Support void addHaving(Operator operator, Condition condition)
Adds a new condition to the having clause of query, connecting it with each other withoperator.- Parameters:
operator- The operator to use to add the conditions to the existing conditionscondition- The condition
-
addHaving
@Support void addHaving(Operator operator, Condition... conditions)
Adds new conditions to the having clause of query, connecting them with each other withoperator.- Parameters:
operator- The operator to use to add the conditions to the existing conditionsconditions- The condition
-
addHaving
@Support void addHaving(Operator operator, Collection<? extends Condition> conditions)
Adds new conditions to the having clause of query, connecting them with each other withoperator.- Parameters:
operator- The operator to use to add the conditions to the existing conditionsconditions- The condition
-
addWindow
@Support({AURORA_POSTGRES,COCKROACHDB,CUBRID,DB2,FIREBIRD_3_0,H2,HANA,INFORMIX,MARIADB,MEMSQL,MYSQL_8_0,ORACLE,POSTGRES,SQLDATAWAREHOUSE,SQLITE,SQLSERVER,SYBASE,TERADATA,VERTICA}) void addWindow(WindowDefinition... definitions)
Adds new window definitions to the window clause of the query.- Parameters:
definitions- The definitions
-
addWindow
@Support({AURORA_POSTGRES,COCKROACHDB,CUBRID,DB2,FIREBIRD_3_0,H2,HANA,INFORMIX,MARIADB,MEMSQL,MYSQL_8_0,ORACLE,POSTGRES,SQLDATAWAREHOUSE,SQLITE,SQLSERVER,SYBASE,TERADATA,VERTICA}) void addWindow(Collection<? extends WindowDefinition> definitions)
Adds new window definitions to the window clause of the query.- Parameters:
definitions- The definitions
-
addQualify
@Support({H2,TERADATA}) void addQualify(Condition condition)
Adds a new condition to the qualify clause of the query, connecting it with each other withOperator.AND.- Parameters:
condition- The condition
-
addQualify
@Support({H2,TERADATA}) void addQualify(Condition... conditions)
Adds new conditions to the qualify clause of the query, connecting them with each other withOperator.AND.- Parameters:
conditions- The condition
-
addQualify
@Support({H2,TERADATA}) void addQualify(Collection<? extends Condition> conditions)
Adds new conditions to the qualify clause of the query, connecting them with each other withOperator.AND.- Parameters:
conditions- The condition
-
addQualify
@Support({H2,TERADATA}) void addQualify(Operator operator, Condition condition)
Adds a new condition to the qualify clause of query, connecting it with each other withoperator.- Parameters:
operator- The operator to use to add the conditions to the existing conditionscondition- The condition
-
addQualify
@Support({H2,TERADATA}) void addQualify(Operator operator, Condition... conditions)
Adds new conditions to the qualify clause of query, connecting them with each other withoperator.- Parameters:
operator- The operator to use to add the conditions to the existing conditionsconditions- The condition
-
addQualify
@Support({H2,TERADATA}) void addQualify(Operator operator, Collection<? extends Condition> conditions)
Adds new conditions to the qualify clause of query, connecting them with each other withoperator.- Parameters:
operator- The operator to use to add the conditions to the existing conditionsconditions- The condition
-
addHint
@Support void addHint(String hint)
Add an Oracle-style hint to the select clause.Example:
DSLContext create = DSL.using(configuration); create.select(field1, field2) .hint("/*+ALL_ROWS*/") .from(table1) .execute();You can also use this clause for any other database, that accepts hints or options at the same syntactic location, e.g. for MySQL's
SQL_CALC_FOUND_ROWSoption:create.select(field1, field2) .hint("SQL_CALC_FOUND_ROWS") .from(table1) .fetch();The outcome of such a query is this:
SELECT [hint] field1, field2 FROM table1
For SQL Server style table hints, see
Table.with(String)- See Also:
Table.with(String)
-
addOption
@Support void addOption(String option)
Add a SQL Server-style query hint to the select clause.Example:
DSLContext create = DSL.using(configuration); create.select(field1, field2) .from(table1) .option("OPTION (OPTIMIZE FOR UNKNOWN)") .execute();You can also use this clause for any other database, that accepts hints or options at the same syntactic location, e.g. for DB2's isolation clause:
create.select(field1, field2) .from(table1) .option("WITH RR USE AND KEEP EXCLUSIVE LOCKS") .execute();The outcome of such a query is this:
SELECT field1, field2 FROM table1 [option]
For SQL Server style table hints, see
Table.with(String)- See Also:
Table.with(String)
-
addConnectBy
@Support({CUBRID,INFORMIX,ORACLE}) void addConnectBy(Condition condition)
Add an Oracle-specificCONNECT BYclause to the query.
-
addConnectByNoCycle
@Support({CUBRID,INFORMIX,ORACLE}) void addConnectByNoCycle(Condition condition)
Add an Oracle-specificCONNECT BY NOCYCLEclause to the query.
-
setConnectByStartWith
@Support({CUBRID,INFORMIX,ORACLE}) void setConnectByStartWith(Condition condition)
Add an Oracle-specificSTART WITHclause to the query'sCONNECT BYclause.
-
addConditions
@Support void addConditions(Condition condition)
Description copied from interface:ConditionProviderAdds a new condition to the query, connecting them to existing conditions withOperator.AND.- Specified by:
addConditionsin interfaceConditionProvider- Parameters:
condition- The condition
-
addConditions
@Support void addConditions(Condition... conditions)
Description copied from interface:ConditionProviderAdds new conditions to the query, connecting them to existing conditions withOperator.AND.- Specified by:
addConditionsin interfaceConditionProvider- Parameters:
conditions- The condition
-
addConditions
@Support void addConditions(Collection<? extends Condition> conditions)
Description copied from interface:ConditionProviderAdds new conditions to the query, connecting them to existing conditions withOperator.AND.- Specified by:
addConditionsin interfaceConditionProvider- Parameters:
conditions- The condition
-
addConditions
@Support void addConditions(Operator operator, Condition condition)
Description copied from interface:ConditionProviderAdds a new condition to the query, connecting them to existing conditions with the provided operator.- Specified by:
addConditionsin interfaceConditionProvidercondition- The condition
-
addConditions
@Support void addConditions(Operator operator, Condition... conditions)
Description copied from interface:ConditionProviderAdds new conditions to the query, connecting them to existing conditions with the provided operator.- Specified by:
addConditionsin interfaceConditionProviderconditions- The condition
-
addConditions
@Support void addConditions(Operator operator, Collection<? extends Condition> conditions)
Description copied from interface:ConditionProviderAdds new conditions to the query, connecting them to existing conditions with the provided operator.- Specified by:
addConditionsin interfaceConditionProviderconditions- The condition
-
addOrderBy
@Support void addOrderBy(OrderField<?>... fields)
Adds ordering fields.- Parameters:
fields- The ordering fields
-
addOrderBy
@Support void addOrderBy(Collection<? extends OrderField<?>> fields)
Adds ordering fields.- Parameters:
fields- The ordering fields
-
addOrderBy
@Support void addOrderBy(int... fieldIndexes)
Adds ordering fields.Indexes start at
1in SQL!Note, you can use
addOrderBy(DSL.val(1).desc())oraddOrderBy(DSL.literal(1).desc())to apply descending ordering- Parameters:
fieldIndexes- The ordering fields
-
setOrderBySiblings
@Support({CUBRID,INFORMIX,ORACLE}) void setOrderBySiblings(boolean orderBySiblings)
Indicate whether theSIBLINGSkeyword should be used in anORDER BYclause to form anORDER SIBLINGS BYclause.This clause can be used only along with Oracle's
CONNECT BYclause, to indicate that the hierarchical ordering should be preserved and elements of each hierarchy should be ordered among themselves.- Parameters:
orderBySiblings-
-
addSeekAfter
@Support void addSeekAfter(Field<?>... fields)
Adds seeking fields.- Parameters:
fields- The seeking fields
-
addSeekAfter
@Support void addSeekAfter(Collection<? extends Field<?>> fields)
Adds seeking fields.- Parameters:
fields- The seeking fields
-
addSeekBefore
@Deprecated @Support void addSeekBefore(Field<?>... fields)
Deprecated.- [#7461] - SEEK BEFORE is not implemented correctlyAdds seeking fields.- Parameters:
fields- The seeking fields
-
addSeekBefore
@Deprecated @Support void addSeekBefore(Collection<? extends Field<?>> fields)
Deprecated.- [#7461] - SEEK BEFORE is not implemented correctlyAdds seeking fields.- Parameters:
fields- The seeking fields
-
addOffset
@Support({AURORA_MYSQL,AURORA_POSTGRES,COCKROACHDB,CUBRID,DB2,DERBY,FIREBIRD,H2,HANA,HSQLDB,INFORMIX,INGRES,MARIADB,MEMSQL,MYSQL,ORACLE,POSTGRES,SQLDATAWAREHOUSE,SQLITE,SQLSERVER,SYBASE,TERADATA,VERTICA}) void addOffset(int offset)
Add anOFFSETclause to the query.If there is no
LIMIT .. OFFSETorTOPclause in your RDBMS, or if your RDBMS does not natively support offsets, this is emulated with aROW_NUMBER()window function and nestedSELECTstatements.
-
addOffset
@Support({AURORA_MYSQL,AURORA_POSTGRES,COCKROACHDB,CUBRID,DB2,DERBY,FIREBIRD,H2,HANA,HSQLDB,INFORMIX,INGRES,MARIADB,MEMSQL,MYSQL,ORACLE,POSTGRES,SQLDATAWAREHOUSE,SQLITE,SQLSERVER,SYBASE,TERADATA,VERTICA}) void addOffset(Number offset)
Add anOFFSETclause to the query.If there is no
LIMIT .. OFFSETorTOPclause in your RDBMS, or if your RDBMS does not natively support offsets, this is emulated with aROW_NUMBER()window function and nestedSELECTstatements.
-
addOffset
@Support({AURORA_MYSQL,AURORA_POSTGRES,COCKROACHDB,CUBRID,DB2,DERBY,FIREBIRD,H2,HANA,HSQLDB,INFORMIX,INGRES,MARIADB,MEMSQL,MYSQL,ORACLE,POSTGRES,SQLDATAWAREHOUSE,SQLITE,SQLSERVER,SYBASE,TERADATA,VERTICA}) void addOffset(Param<? extends Number> offset)
Add anOFFSETclause to the query using a named parameter.If there is no
LIMIT .. OFFSETorTOPclause in your RDBMS, or if your RDBMS does not natively support offsets, this is emulated with aROW_NUMBER()window function and nestedSELECTstatements.
-
addLimit
@Support void addLimit(int numberOfRows)
Limit the results of this select.This is the same as calling
addLimit(int, int)with offset = 0- Parameters:
numberOfRows- The number of rows to return
-
addLimit
@Support void addLimit(Number numberOfRows)
Limit the results of this select.This is the same as calling
addLimit(int, int)with offset = 0- Parameters:
numberOfRows- The number of rows to return
-
addLimit
@Support({AURORA_MYSQL,AURORA_POSTGRES,COCKROACHDB,CUBRID,DB2,DERBY,FIREBIRD,H2,HANA,HSQLDB,INFORMIX,MARIADB,MEMSQL,MYSQL,ORACLE,POSTGRES,SQLDATAWAREHOUSE,SQLITE,SQLSERVER,SYBASE,TERADATA,VERTICA}) void addLimit(Param<? extends Number> numberOfRows)
Limit the results of this select using named parameters.Note that some dialects do not support bind values at all in
LIMITorTOPclauses!If there is no
LIMITorTOPclause in your RDBMS, or theLIMITorTOPclause does not support bind values, this may be emulated with aROW_NUMBER()window function and nestedSELECTstatements.This is the same as calling
addLimit(int, int)with offset = 0- Parameters:
numberOfRows- The number of rows to return
-
addLimit
@Support({AURORA_MYSQL,AURORA_POSTGRES,COCKROACHDB,CUBRID,DB2,DERBY,FIREBIRD,H2,HANA,HSQLDB,INFORMIX,INGRES,MARIADB,MEMSQL,MYSQL,ORACLE,POSTGRES,SQLDATAWAREHOUSE,SQLITE,SQLSERVER,SYBASE,TERADATA,VERTICA}) void addLimit(int offset, int numberOfRows)
Limit the results of this select.Note that some dialects do not support bind values at all in
LIMITorTOPclauses!If there is no
LIMITorTOPclause in your RDBMS, or if your RDBMS does not natively support offsets, this is emulated with aROW_NUMBER()window function and nestedSELECTstatements.- Parameters:
offset- The lowest offset starting at 0numberOfRows- The number of rows to return
-
addLimit
@Support({AURORA_MYSQL,AURORA_POSTGRES,COCKROACHDB,CUBRID,DB2,DERBY,FIREBIRD,H2,HANA,HSQLDB,INFORMIX,INGRES,MARIADB,MEMSQL,MYSQL,ORACLE,POSTGRES,SQLDATAWAREHOUSE,SQLITE,SQLSERVER,SYBASE,TERADATA,VERTICA}) void addLimit(Number offset, Number numberOfRows)
Limit the results of this select.Note that some dialects do not support bind values at all in
LIMITorTOPclauses!If there is no
LIMITorTOPclause in your RDBMS, or if your RDBMS does not natively support offsets, this is emulated with aROW_NUMBER()window function and nestedSELECTstatements.- Parameters:
offset- The lowest offset starting at 0numberOfRows- The number of rows to return
-
addLimit
@Support({AURORA_MYSQL,AURORA_POSTGRES,COCKROACHDB,CUBRID,DB2,DERBY,FIREBIRD,H2,HANA,HSQLDB,INFORMIX,MARIADB,MEMSQL,MYSQL,ORACLE,POSTGRES,SQLDATAWAREHOUSE,SQLITE,SQLSERVER,SYBASE,TERADATA,VERTICA}) void addLimit(Param<Integer> offset, int numberOfRows)
Limit the results of this select.Note that some dialects do not support bind values at all in
LIMITorTOPclauses!If there is no
LIMITorTOPclause in your RDBMS, or theLIMITorTOPclause does not support bind values, or if your RDBMS does not natively support offsets, this may be emulated with aROW_NUMBER()window function and nestedSELECTstatements.- Parameters:
offset- The lowest offset starting at 0numberOfRows- The number of rows to return
-
addLimit
@Support({AURORA_MYSQL,AURORA_POSTGRES,COCKROACHDB,CUBRID,DB2,DERBY,FIREBIRD,H2,HANA,HSQLDB,INFORMIX,MARIADB,MEMSQL,MYSQL,ORACLE,POSTGRES,SQLDATAWAREHOUSE,SQLITE,SQLSERVER,SYBASE,TERADATA,VERTICA}) void addLimit(Param<? extends Number> offset, Number numberOfRows)
Limit the results of this select.Note that some dialects do not support bind values at all in
LIMITorTOPclauses!If there is no
LIMITorTOPclause in your RDBMS, or theLIMITorTOPclause does not support bind values, or if your RDBMS does not natively support offsets, this may be emulated with aROW_NUMBER()window function and nestedSELECTstatements.- Parameters:
offset- The lowest offset starting at 0numberOfRows- The number of rows to return
-
addLimit
@Support({AURORA_MYSQL,AURORA_POSTGRES,COCKROACHDB,CUBRID,DB2,DERBY,FIREBIRD,H2,HANA,HSQLDB,INFORMIX,MARIADB,MEMSQL,MYSQL,ORACLE,POSTGRES,SQLDATAWAREHOUSE,SQLITE,SQLSERVER,SYBASE,TERADATA,VERTICA}) void addLimit(int offset, Param<Integer> numberOfRows)
Limit the results of this select using named parameters.Note that some dialects do not support bind values at all in
LIMITorTOPclauses!If there is no
LIMITorTOPclause in your RDBMS, or theLIMITorTOPclause does not support bind values, or if your RDBMS does not natively support offsets, this may be emulated with aROW_NUMBER()window function and nestedSELECTstatements.- Parameters:
offset- The lowest offset starting at 0numberOfRows- The number of rows to return
-
addLimit
@Support({AURORA_MYSQL,AURORA_POSTGRES,COCKROACHDB,CUBRID,DB2,DERBY,FIREBIRD,H2,HANA,HSQLDB,INFORMIX,MARIADB,MEMSQL,MYSQL,ORACLE,POSTGRES,SQLDATAWAREHOUSE,SQLITE,SQLSERVER,SYBASE,TERADATA,VERTICA}) void addLimit(Number offset, Param<? extends Number> numberOfRows)
Limit the results of this select using named parameters.Note that some dialects do not support bind values at all in
LIMITorTOPclauses!If there is no
LIMITorTOPclause in your RDBMS, or theLIMITorTOPclause does not support bind values, or if your RDBMS does not natively support offsets, this may be emulated with aROW_NUMBER()window function and nestedSELECTstatements.- Parameters:
offset- The lowest offset starting at 0numberOfRows- The number of rows to return
-
addLimit
@Support({AURORA_MYSQL,AURORA_POSTGRES,COCKROACHDB,CUBRID,DB2,DERBY,FIREBIRD,H2,HANA,HSQLDB,INFORMIX,MARIADB,MEMSQL,MYSQL,ORACLE,POSTGRES,SQLDATAWAREHOUSE,SQLITE,SQLSERVER,SYBASE,TERADATA,VERTICA}) void addLimit(Param<? extends Number> offset, Param<? extends Number> numberOfRows)
Limit the results of this select using named parameters.Note that some dialects do not support bind values at all in
LIMITorTOPclauses!If there is no
LIMITorTOPclause in your RDBMS, or theLIMITorTOPclause does not support bind values, or if your RDBMS does not natively support offsets, this may be emulated with aROW_NUMBER()window function and nestedSELECTstatements.- Parameters:
offset- The lowest offset starting at 0numberOfRows- The number of rows to return
-
setLimitPercent
@Support({H2,ORACLE12C,SQLSERVER}) void setLimitPercent(boolean percent)
Add thePERCENTclause to aLIMITclause.
-
setWithTies
@Support({AURORA_POSTGRES,COCKROACHDB,CUBRID,DB2,FIREBIRD_3_0,H2,HANA,INFORMIX,MARIADB,MYSQL_8_0,ORACLE,POSTGRES,REDSHIFT,SQLDATAWAREHOUSE,SQLSERVER,SYBASE,TERADATA,VERTICA}) void setWithTies(boolean withTies)
Add theWITH TIESclause to aLIMITclause.
-
setForUpdate
@Support({ASE,AURORA_MYSQL,AURORA_POSTGRES,COCKROACHDB,CUBRID,DB2,DERBY,FIREBIRD,H2,HANA,HSQLDB,INFORMIX,INGRES,MARIADB,MEMSQL,MYSQL,ORACLE,POSTGRES,SQLDATAWAREHOUSE,SQLSERVER,SYBASE,TERADATA}) void setForUpdate(boolean forUpdate)
Sets the "FOR UPDATE" flag onto the query.Native implementation
This has been observed to be supported by any of these dialects:
- DB2 FOR UPDATE and similar clauses
- Derby's FOR UPDATE clause
- H2's FOR UPDATE clause
- HSQLDB's FOR UPDATE clause
- MySQL's InnoDB locking reads
- Oracle's PL/SQL FOR UPDATE clause
- Postgres FOR UPDATE / FOR SHARE
emulation
These dialects can emulate the
FOR UPDATEclause using a cursor. The cursor is handled by the JDBC driver, atPreparedStatementconstruction time, when callingConnection.prepareStatement(String, int, int)withResultSet.CONCUR_UPDATABLE. jOOQ handles emulation of aFOR UPDATEclause usingCONCUR_UPDATABLEfor these dialects:Note: This emulation may not be efficient for large result sets!
Not supported
These dialects are known not to support the
FOR UPDATEclause in regular SQL:If your dialect does not support this clause, jOOQ will still render it, if you apply it to your query. This might then cause syntax errors reported either by your database or your JDBC driver.
You shouldn't combine this with
setForShare(boolean)- Parameters:
forUpdate- The flag's value
-
setForNoKeyUpdate
@Support({AURORA_POSTGRES,COCKROACHDB,POSTGRES}) void setForNoKeyUpdate(boolean forNoKeyUpdate)
Sets the "FOR NO KEY UPDATE" flag onto the query.
-
setForUpdateOf
@Support({COCKROACHDB,DB2,DERBY,FIREBIRD,H2,HANA,HSQLDB,INFORMIX,INGRES,ORACLE,SYBASE}) void setForUpdateOf(Field<?>... fields)
Some RDBMS allow for specifying the fields that should be locked by theFOR UPDATEclause, instead of the full row.This automatically sets the
setForUpdate(boolean)flag, and unsets thesetForShare(boolean)flag, if it was previously set.This has been observed to be natively supported by any of these dialects:
- DB2
- Derby
- H2
- HSQLDB
- Ingres
- Oracle
- Sybase
Note, that
SQLDialect.DB2has some stricter requirements regarding the updatability of fields. Refer to the DB2 documentation for further details- Parameters:
fields- The fields that should be locked
-
setForUpdateOf
@Support({COCKROACHDB,DB2,DERBY,FIREBIRD,H2,HANA,HSQLDB,INFORMIX,INGRES,ORACLE,SYBASE}) void setForUpdateOf(Collection<? extends Field<?>> fields)
Some RDBMS allow for specifying the fields that should be locked by theFOR UPDATEclause, instead of the full row.- See Also:
setForUpdateOf(Field...)
-
setForUpdateOf
@Support({AURORA_POSTGRES,COCKROACHDB,DB2,DERBY,FIREBIRD,H2,HANA,HSQLDB,INFORMIX,INGRES,MYSQL_8_0,ORACLE,POSTGRES,SYBASE}) void setForUpdateOf(Table<?>... tables)
Some RDBMS allow for specifying the tables that should be locked by theFOR UPDATEclause, instead of the full row.This automatically sets the
setForUpdate(boolean)flag, and unsets thesetForShare(boolean)flag, if it was previously set.This has been observed to be natively supported by any of these dialects:
- Postgres
- H2
- HSQLDB
- Sybase
jOOQ emulates this by locking all known fields of [
tables] for any of these dialects:- DB2
- Derby
- Ingres
- Oracle
- Parameters:
tables- The tables that should be locked
-
setForUpdateWait
@Support({MARIADB_10_3,ORACLE}) void setForUpdateWait(int seconds)
Some RDBMS allow for specifying the locking mode for the appliedFOR UPDATEclause. In this case, the session will wait for someseconds, before aborting the lock acquirement if the lock is not available.This automatically sets the
setForUpdate(boolean)flag, and unsets thesetForShare(boolean)flag, if it was previously set.This has been observed to be supported by any of these dialects:
- Oracle
- Parameters:
seconds- The number of seconds to wait for a lock
-
setForUpdateNoWait
@Support({AURORA_POSTGRES,MARIADB_10_3,MYSQL_8_0,ORACLE,POSTGRES}) void setForUpdateNoWait()
Some RDBMS allow for specifying the locking mode for the appliedFOR UPDATEclause. In this case, the session will not wait before aborting the lock acquirement if the lock is not available.This automatically sets the
setForUpdate(boolean)flag, and unsets thesetForShare(boolean)flag, if it was previously set.This has been observed to be supported by any of these dialects:
- Oracle
-
setForUpdateSkipLocked
@Support({AURORA_POSTGRES,MYSQL_8_0,ORACLE,POSTGRES_9_5}) void setForUpdateSkipLocked()
Some RDBMS allow for specifying the locking mode for the appliedFOR UPDATEclause. In this case, the session will skip all locked rows from the select statement, whose lock is not available.This automatically sets the
setForUpdate(boolean)flag, and unsets thesetForShare(boolean)flag, if it was previously set.This has been observed to be supported by any of these dialects:
- Oracle
-
setForShare
@Support({AURORA_MYSQL,AURORA_POSTGRES,COCKROACHDB,MARIADB,MYSQL,POSTGRES}) void setForShare(boolean forShare)
Sets the "FOR SHARE" flag onto the query.This has been observed to be supported by any of these dialects:
If your dialect does not support this clause, jOOQ will still render it, if you apply it to your query. This might then cause syntax errors reported either by your database or your JDBC driver.
You shouldn't combine this with
setForUpdate(boolean)- Parameters:
forShare- The flag's value
-
setForKeyShare
@Support({AURORA_POSTGRES,COCKROACHDB,POSTGRES}) void setForKeyShare(boolean forKeyShare)
Sets the "FOR KEY SHARE" flag onto the query.
-
setWithCheckOption
@Support(ORACLE) @Pro void setWithCheckOption()
Add aWITH CHECK OPTIONclause to the end of the subquery.
-
-