Exposed 1.0.0-beta-3 Help

Numeric, boolean, and string

The exposed-core module provides support for various numeric, boolean, and string types.

Basic usage

Here's an example of using different data types in a table definition:

import org.jetbrains.exposed.v1.core.* class BasicTypesExamples { companion object { private const val NAME_LENGTH = 50 private const val RATING_TOTAL_DIGITS = 5 private const val RATING_DECIMAL_DIGITS = 2 } object Users : Table() { val id = integer("id").autoIncrement() val name = varchar("name", NAME_LENGTH) val bio = text("bio") val age = short("age") val rating = decimal("rating", RATING_TOTAL_DIGITS, RATING_DECIMAL_DIGITS) // 5 total digits, 2 after decimal point val isActive = bool("is_active") override val primaryKey = PrimaryKey(id) } }

Numeric types

integer()

Maps to database INT. Used for storing whole numbers within the range of -2^31 to 2^31-1.

short()

Maps to database SMALLINT. Used for storing smaller whole numbers within the range of -32,768 to 32,767.

long()

Maps to database BIGINT. Used for storing large whole numbers within the range of -2^63 to 2^63-1.

float()

Maps to database FLOAT. Used for storing approximate decimal numbers.

  • PostgreSQL: Maps to REAL

decimal()

Maps to database DECIMAL with specified scale and precision. Used for storing exact decimal numbers where precision is important.

Boolean type

bool()

Maps to database BOOLEAN. Used for storing true/false values.

Database-specific mappings:

  • Oracle: Maps to CHAR(1)

  • SQLServer: Maps to BIT

String types

char()

Maps to database CHAR. Used for storing fixed-length character strings.

varchar()

Maps to database VARCHAR with specified length. Used for storing variable-length character strings with a maximum length limit.

text()

Maps to database TEXT. Used for storing large variable-length character strings without length limit.

Last modified: 03 July 2025