Defining Tables with the Table DSL
Define typed table schemas with columns, primary keys, and foreign keys.
Exposed Table Objects
In Exposed, database tables are represented as Kotlin singleton objects that extend Table (Query DSL) or IntIdTable/LongIdTable/UUIDTable (DAO layer). Column definitions are Kotlin properties.
A Basic Table Definition
Extend Table and define columns using the built-in column factory functions:
import org.jetbrains.exposed.sql.Table
object Users : Table("users") {
val id = long("id").autoIncrement()
val name = varchar("name", 100)
val email = varchar("email", 255).uniqueIndex()
val age = integer("age").nullable()
override val primaryKey = PrimaryKey(id)
}