references

infix fun <T : Comparable<T>, S : T, C : Column<S>> C.references(ref: Column<T>): C

Creates a reference from this @receiver column to a ref column.

This is a short infix version of references() with default onDelete and onUpdate behavior.

Receiver

A column from the current table where reference values will be stored.

Parameters

ref

A column from another table which will be used as a "parent".

Samples

org.jetbrains.exposed.sql.tests.shared.dml.JoinTests.testJoin04
fun <T : Comparable<T>, S : T, C : Column<S>> C.references(ref: Column<T>, onDelete: ReferenceOption? = null, onUpdate: ReferenceOption? = null, fkName: String? = null): C

Creates a reference from this @receiver column to a ref column with onDelete, onUpdate, and fkName options. onDelete and onUpdate options describe the behavior for how links between tables will be checked when deleting or changing corresponding columns' values. Such a relationship will be represented as a FOREIGN KEY constraint on table creation.

Receiver

A column from the current table where reference values will be stored.

Parameters

ref

A column from another table which will be used as a "parent".

onDelete

Optional ReferenceOption for cases when a linked row from a parent table will be deleted.

onUpdate

Optional ReferenceOption for cases when a value in a referenced column will be changed.

fkName

Optional foreign key constraint name.

Samples

org.jetbrains.exposed.sql.tests.sqlite.ForeignKeyConstraintTests.testUpdateAndDeleteRulesReadCorrectlyWhenSpecifiedInChildTable
@JvmName(name = "referencesById")
fun <T : Comparable<T>, S : T, C : Column<S>> C.references(ref: Column<EntityID<T>>, onDelete: ReferenceOption? = null, onUpdate: ReferenceOption? = null, fkName: String? = null): C

Creates a reference from this @receiver column to a ref column with onDelete, onUpdate, and fkName options. onDelete and onUpdate options describe the behavior for how links between tables will be checked when deleting or changing corresponding columns' values. Such a relationship will be represented as a FOREIGN KEY constraint on table creation.

Receiver

A column from the current table where reference values will be stored.

Parameters

ref

A column from another table which will be used as a "parent".

onDelete

Optional ReferenceOption for cases when a linked row from a parent table will be deleted.

onUpdate

Optional ReferenceOption for cases when a value in a referenced column will be changed.

fkName

Optional foreign key constraint name.

Samples

org.jetbrains.exposed.sql.tests.shared.ddl.CreateMissingTablesAndColumnsTests.ExplicitTable