# Package-level declarations

## Types

Database
Link copied to clipboard
class Database : DatabaseApi

Class representing the underlying JDBC database to which connections are made and on which transaction tasks are performed.

DatabaseConnectionAutoRegistration
Link copied to clipboard
interface DatabaseConnectionAutoRegistration : Function1<Connection, ExposedConnection<*>>

Represents an ExposedConnection that is loaded whenever a connection is accessed by a Database instance.

EmptySizedIterable
Link copied to clipboard
class EmptySizedIterable<out T> : SizedIterable<T> , Iterator<T>

Represents a SizedIterable that is empty and cannot be iterated over.

Except
Link copied to clipboard
class Except(firstStatement: AbstractQuery<*>, secondStatement: AbstractQuery<*>) : SetOperation

Represents an SQL operation that returns the distinct results of firstStatement that are not common to secondStatement.

ExplainBlockingExecutable
Link copied to clipboard
open class ExplainBlockingExecutable(val statement: ExplainQuery) : BlockingExecutable<ResultApi, ExplainQuery> , Iterable<ExplainResultRow>

Represents the execution logic for an SQL statement that obtains information about a statement execution plan.

ExposedConnectionImpl
Link copied to clipboard
class ExposedConnectionImpl : DatabaseConnectionAutoRegistration

Class responsible for the actual loading when a Database instance accesses a connection.

Intersect
Link copied to clipboard
class Intersect(firstStatement: AbstractQuery<*>, secondStatement: AbstractQuery<*>) : SetOperation

Represents an SQL operation that returns only the common rows from two query results, without any duplicates.

JdbcTransaction
Link copied to clipboard
open class JdbcTransaction(transactionImpl: JdbcTransactionInterface) : Transaction, JdbcTransactionInterface

Class representing a unit block of work that is performed on a database using a JDBC driver.

LazySizedCollection
Link copied to clipboard
class LazySizedCollection<out T>(_delegate: SizedIterable<T>) : SizedIterable<T>

Represents a SizedIterable whose elements are only loaded on first access.

LazySizedIterable
Link copied to clipboard
interface LazySizedIterable<T> : SizedIterable<T>

Represents the iterable elements of a database result, which are stored once loaded on first access.

Query
Link copied to clipboard
open class Query(var set: FieldSet, where: Op<Boolean>?) : AbstractQuery<Query> , BlockingExecutable<ResultApi, Query> , SizedIterable<ResultRow>

Class representing an SQL `SELECT` statement on which query clauses can be built.

SchemaUtils
Link copied to clipboard
object SchemaUtils : SchemaUtilityApi

Utility functions that assist with creating, altering, and dropping database schema objects.

SetOperation
Link copied to clipboard
sealed class SetOperation : AbstractQuery<SetOperation> , BlockingExecutable<ResultApi, SetOperation> , SizedIterable<ResultRow>

Represents an SQL operation that combines the results of multiple queries into a single result.

SizedCollection
Link copied to clipboard
class SizedCollection<out T>(val delegate: Collection<T>) : SizedIterable<T>

Represents a SizedIterable that defers to the specified delegate collection.

SizedIterable
Link copied to clipboard
interface SizedIterable<out T> : Iterable<T>

Represents the iterable elements of a database result.

Union
Link copied to clipboard
class Union(firstStatement: AbstractQuery<*>, secondStatement: AbstractQuery<*>) : SetOperation

Represents an SQL operation that combines all results from two queries, without any duplicates.

UnionAll
Link copied to clipboard
class UnionAll(firstStatement: AbstractQuery<*>, secondStatement: AbstractQuery<*>) : SetOperation

Represents an SQL operation that combines all results from two queries, with duplicates included.

## Properties

name
Link copied to clipboard
val Database.name: String

Returns the name of the database obtained from its connection URL.

## Functions

andHaving
Link copied to clipboard
fun Query.andHaving(andPart: () -> Op<Boolean>): Query

Mutate Query instance and add `andPart` to having condition with `and` operator.

andWhere
Link copied to clipboard
fun Query.andWhere(andPart: () -> Op<Boolean>): Query

Mutate Query instance and add `andPart` to where condition with `and` operator.

batchInsert
Link copied to clipboard
fun <T : Table, E> T.batchInsert(data: Iterable<E>, ignore: Boolean = false, shouldReturnGeneratedValues: Boolean = true, body: BatchInsertStatement.(E) -> Unit): List<ResultRow>
fun <T : Table, E> T.batchInsert(data: Sequence<E>, ignore: Boolean = false, shouldReturnGeneratedValues: Boolean = true, body: BatchInsertStatement.(E) -> Unit): List<ResultRow>

Represents the SQL statement that batch inserts new rows into a table.

batchReplace
Link copied to clipboard
fun <T : Table, E : Any> T.batchReplace(data: Iterable<E>, shouldReturnGeneratedValues: Boolean = true, body: BatchReplaceStatement.(E) -> Unit): List<ResultRow>
fun <T : Table, E : Any> T.batchReplace(data: Sequence<E>, shouldReturnGeneratedValues: Boolean = true, body: BatchReplaceStatement.(E) -> Unit): List<ResultRow>

Represents the SQL statement that either batch inserts new rows into a table, or, if insertions violate unique constraints, first deletes the existing rows before inserting new rows.

batchUpsert
Link copied to clipboard
fun <T : Table, E : Any> T.batchUpsert(data: Iterable<E>, vararg keys: Column<*>, onUpdate: UpsertBuilder.(UpdateStatement) -> Unit? = null, onUpdateExclude: List<Column<*>>? = null, where: () -> Op<Boolean>? = null, shouldReturnGeneratedValues: Boolean = true, body: BatchUpsertStatement.(E) -> Unit): List<ResultRow>
fun <T : Table, E : Any> T.batchUpsert(data: Sequence<E>, vararg keys: Column<*>, onUpdate: UpsertBuilder.(UpdateStatement) -> Unit? = null, onUpdateExclude: List<Column<*>>? = null, where: () -> Op<Boolean>? = null, shouldReturnGeneratedValues: Boolean = true, body: BatchUpsertStatement.(E) -> Unit): List<ResultRow>

Represents the SQL statement that either batch inserts new rows into a table, or updates the existing rows if insertions violate unique constraints.

delete
Link copied to clipboard
fun Join.delete(targetTable: Table, vararg targetTables: Table, ignore: Boolean = false, limit: Int? = null): Int

Represents the SQL statement that deletes all rows from a table in a join relation.

fun Join.delete(targetTable: Table, vararg targetTables: Table, ignore: Boolean = false, limit: Int? = null, where: () -> Op<Boolean>): Int

Represents the SQL statement that deletes rows from a table in a join relation.

deleteAll
Link copied to clipboard
fun Table.deleteAll(): Int

Represents the SQL statement that deletes all rows in a table.

deleteIgnoreWhere
Link copied to clipboard
fun <T : Table> T.deleteIgnoreWhere(limit: Int? = null, op: T.() -> Op<Boolean>): Int

Represents the SQL statement that deletes only rows in a table that match the provided op, while ignoring any possible errors that occur during the process.

deleteReturning
Link copied to clipboard
fun <T : Table> T.deleteReturning(returning: List<Expression<*>> = columns): ReturningBlockingExecutable

Represents the SQL statement that deletes all rows in a table and returns specified data from the deleted rows.

fun <T : Table> T.deleteReturning(returning: List<Expression<*>> = columns, where: () -> Op<Boolean>): ReturningBlockingExecutable

Represents the SQL statement that deletes rows in a table and returns specified data from the deleted rows.

deleteWhere
Link copied to clipboard
fun <T : Table> T.deleteWhere(limit: Int? = null, op: T.() -> Op<Boolean>): Int

Represents the SQL statement that deletes only rows in a table that match the provided op.

emptySized
Link copied to clipboard
fun <T> emptySized(): SizedIterable<T>

Returns an EmptySizedIterable.

except
Link copied to clipboard
fun AbstractQuery<*>.except(other: Query): Except

Returns only distinct results from this query that are NOT common to the results of other.

exists
Link copied to clipboard
fun Schema.exists(): Boolean

Checks if this schema exists or not.

fun Sequence.exists(): Boolean

Returns whether this sequence exists in the database.

fun Table.exists(): Boolean

Returns whether this table exists in the database.

explain
Link copied to clipboard
fun JdbcTransaction.explain(analyze: Boolean = false, options: String? = null, body: StatementBuilder.() -> Statement<*>): ExplainBlockingExecutable

Creates an ExplainQuery using the `EXPLAIN` keyword, which obtains information about a statement execution plan.

insert
Link copied to clipboard
fun <T : Table> T.insert(body: T.(InsertStatement<Number>) -> Unit): InsertStatement<Number>

Represents the SQL statement that inserts a new row into a table.

fun <T : Table> T.insert(selectQuery: AbstractQuery<*>, columns: List<Column<*>>? = null): Int?

Represents the SQL statement that uses data retrieved from a selectQuery to insert new rows into a table.

insertAndGetId
Link copied to clipboard
fun <Key : Any, T : IdTable<Key>> T.insertAndGetId(body: T.(InsertStatement<EntityID<Key>>) -> Unit): EntityID<Key>

Represents the SQL statement that inserts a new row into a table.

insertIgnore
Link copied to clipboard
fun <T : Table> T.insertIgnore(body: T.(UpdateBuilder<*>) -> Unit): InsertStatement<Long>

Represents the SQL statement that inserts a new row into a table, while ignoring any possible errors that occur during the process.

fun <T : Table> T.insertIgnore(selectQuery: AbstractQuery<*>, columns: List<Column<*>>? = null): Int?

Represents the SQL statement that uses data retrieved from a selectQuery to insert new rows into a table, while ignoring any possible errors that occur during the process.

insertIgnoreAndGetId
Link copied to clipboard
fun <Key : Any, T : IdTable<Key>> T.insertIgnoreAndGetId(body: T.(UpdateBuilder<*>) -> Unit): EntityID<Key>?

Represents the SQL statement that inserts a new row into a table, while ignoring any possible errors that occur during the process.

insertReturning
Link copied to clipboard
fun <T : Table> T.insertReturning(returning: List<Expression<*>> = columns, ignoreErrors: Boolean = false, body: T.(InsertStatement<Number>) -> Unit): ReturningBlockingExecutable

Represents the SQL statement that inserts new rows into a table and returns specified data from the inserted rows.

intersect
Link copied to clipboard
fun AbstractQuery<*>.intersect(other: Query): Intersect

Returns only results from this query that are common to the results of other, WITHOUT including any duplicates.

mapLazy
Link copied to clipboard
infix fun <T, R> SizedIterable<T>.mapLazy(f: (T) -> R): SizedIterable<R>

Returns a SizedIterable containing the lazily evaluated results of applying the function f to each original element.

mergeFrom
Link copied to clipboard
fun <D : Table, S : Table> D.mergeFrom(source: S, body: MergeTableStatement.() -> Unit): MergeTableStatement
fun <D : Table, S : Table> D.mergeFrom(source: S, on: () -> Op<Boolean>, body: MergeTableStatement.() -> Unit): MergeTableStatement

Performs an SQL MERGE operation to insert, update, or delete records in the target table based on a comparison with a source table.

fun <T : Table> T.mergeFrom(selectQuery: QueryAlias, on: () -> Op<Boolean>, body: MergeSelectStatement.() -> Unit): MergeSelectStatement

Performs an SQL MERGE operation to insert, update, or delete records in the target table based on a comparison with a select query source.

orHaving
Link copied to clipboard
fun Query.orHaving(orPart: () -> Op<Boolean>): Query

Mutate Query instance and add `orPart` to having condition with `or` operator.

orWhere
Link copied to clipboard
fun Query.orWhere(orPart: () -> Op<Boolean>): Query

Mutate Query instance and add `orPart` to where condition with `or` operator.

replace
Link copied to clipboard
fun <T : Table> T.replace(body: T.(UpdateBuilder<*>) -> Unit): ReplaceStatement<Long>

Represents the SQL statement that either inserts a new row into a table, or, if insertion would violate a unique constraint, first deletes the existing row before inserting a new row.

fun <T : Table> T.replace(selectQuery: AbstractQuery<*>, columns: List<Column<*>>? = null): Int?

Represents the SQL statement that uses data retrieved from a selectQuery to either insert a new row into a table, or, if insertion would violate a unique constraint, first delete the existing row before inserting a new row.

select
Link copied to clipboard
fun ColumnSet.select(columns: List<Expression<*>>): Query

Creates a `SELECT` Query using a list of columns or expressions from this ColumnSet.

fun ColumnSet.select(column: Expression<*>, vararg columns: Expression<*>): Query

Creates a `SELECT` Query by selecting either a single column, or a subset of columns, from this ColumnSet.

selectAll
Link copied to clipboard
fun FieldSet.selectAll(): Query

Creates a `SELECT` Query by selecting all columns from this ColumnSet.

union
Link copied to clipboard
fun AbstractQuery<*>.union(other: Query): Union

Combines all results from this query with the results of other, WITHOUT including duplicates.

unionAll
Link copied to clipboard
fun AbstractQuery<*>.unionAll(other: Query): UnionAll

Combines all results from this query with the results of other, WITH duplicates included.

update
Link copied to clipboard
fun <T : Table> T.update(limit: Int? = null, body: T.(UpdateStatement) -> Unit): Int

Represents the SQL statement that updates all rows of a table.

fun Join.update(limit: Int? = null, body: (UpdateStatement) -> Unit): Int

Represents the SQL statement that updates all rows of a join relation.

fun <T : Table> T.update(where: () -> Op<Boolean>, limit: Int? = null, body: T.(UpdateStatement) -> Unit): Int

Represents the SQL statement that updates rows of a table.

fun Join.update(where: () -> Op<Boolean>, limit: Int? = null, body: (UpdateStatement) -> Unit): Int

Represents the SQL statement that updates rows of a join relation.

updateReturning
Link copied to clipboard
fun <T : Table> T.updateReturning(returning: List<Expression<*>> = columns, body: T.(UpdateStatement) -> Unit): ReturningBlockingExecutable

Represents the SQL statement that updates all rows of a table and returns specified data from the updated rows.

fun <T : Table> T.updateReturning(returning: List<Expression<*>> = columns, where: () -> Op<Boolean>, body: T.(UpdateStatement) -> Unit): ReturningBlockingExecutable

Represents the SQL statement that updates rows of a table and returns specified data from the updated rows.

upsert
Link copied to clipboard
fun <T : Table> T.upsert(vararg keys: Column<*>, onUpdate: UpsertBuilder.(UpdateStatement) -> Unit? = null, onUpdateExclude: List<Column<*>>? = null, where: () -> Op<Boolean>? = null, body: T.(UpsertStatement<Long>) -> Unit): UpsertStatement<Long>

Represents the SQL statement that either inserts a new row into a table, or updates the existing row if insertion would violate a unique constraint.

upsertReturning
Link copied to clipboard
fun <T : Table> T.upsertReturning(vararg keys: Column<*>, returning: List<Expression<*>> = columns, onUpdate: UpsertBuilder.(UpdateStatement) -> Unit? = null, onUpdateExclude: List<Column<*>>? = null, where: () -> Op<Boolean>? = null, body: T.(UpsertStatement<Long>) -> Unit): ReturningBlockingExecutable

Represents the SQL statement that either inserts a new row into a table, or updates the existing row if insertion would violate a unique constraint, and also returns specified data from the modified rows.