Exposed 1.0.0-beta-2 Help

Table types

In Exposed, the Table class is the core abstraction for defining database tables. This class provides methods to define various column types, constraints, and other table-specific properties.

Table is located in the org.jetbrains.exposed.v1.sql package of the exposed-core module.

The following example defines a table with an auto-incrementing integer id column and string name and director column:

import org.jetbrains.exposed.v1.core.Table const val MAX_VARCHAR_LENGTH = 50 object StarWarsFilmsTable : Table() { val id = integer("id").autoIncrement() val sequelId = integer("sequel_id").uniqueIndex() val name = varchar("name", MAX_VARCHAR_LENGTH) val director = varchar("director", MAX_VARCHAR_LENGTH) }
CREATE TABLE IF NOT EXISTS STARWARSFILMS (ID INT AUTO_INCREMENT NOT NULL, SEQUEL_ID INT NOT NULL, "name" VARCHAR(50) NOT NULL, DIRECTOR VARCHAR(50) NOT NULL)

For more information on defining and configuring tables in Exposed, see Working with tables.

Last modified: 27 May 2025