# ColumnInfo

Artifact: [androidx.room3:room3-common](https://developer.android.com/jetpack/androidx/releases/room3) [View Source](https://cs.android.com/search?q=file:androidx/room3/ColumnInfo.kt+class:androidx.room3.ColumnInfo) Added in [3.0.0](https://developer.android.com/jetpack/androidx/releases/room3#3.0.0)

*** ** * ** ***

Common/AllAndroid/JVMNative/C/iOSJavaScript
- Cmn

  ```
  @Target(allowedTargets = [AnnotationTarget.PROPERTY, AnnotationTarget.FIELD, AnnotationTarget.FUNCTION])
  @Retention(value = AnnotationRetention.BINARY)
  annotation ColumnInfo
  ```

*** ** * ** ***

Allows specific customization about the column associated with the annotated property.

For example, you can specify a column name for the property or change the column's type affinity.

## Summary

| ### Nested types |
|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/IntDef(value = [1, 2, 3, 4, 5, 6]) @https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.annotation/-retention/index.html(value = https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.annotation/-annotation-retention/-b-i-n-a-r-y/index.html) annotation https://developer.android.com/reference/kotlin/androidx/room3/ColumnInfo.Collate` |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/IntDef(value = [1, 2, 3, 4, 5]) @https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.annotation/-retention/index.html(value = https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.annotation/-annotation-retention/-b-i-n-a-r-y/index.html) annotation https://developer.android.com/reference/kotlin/androidx/room3/ColumnInfo.SQLiteTypeAffinity` The SQLite column type constants that can be used in `https://developer.android.com/reference/kotlin/androidx/room3/ColumnInfo#typeAffinity()` |

| ### Constants |
|---|---|---|
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/room3/ColumnInfo#BINARY() = 2` Collation sequence for case-sensitive match. | Cmn |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/room3/ColumnInfo#BLOB() = 5` Column affinity constant for binary data. | Cmn |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/room3/ColumnInfo#INHERIT_FIELD_NAME()` Constant to let Room inherit the property name as the column name. | Cmn |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/room3/ColumnInfo#INTEGER() = 3` Column affinity constant for integers or booleans. | Cmn |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/room3/ColumnInfo#LOCALIZED() = 5` Collation sequence that uses system's current locale. | Cmn |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/room3/ColumnInfo#NOCASE() = 3` Collation sequence for case-insensitive match. | Cmn |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/room3/ColumnInfo#REAL() = 4` Column affinity constant for floats or doubles. | Cmn |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/room3/ColumnInfo#RTRIM() = 4` Collation sequence for case-sensitive match except that trailing space characters are ignored. | Cmn |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/room3/ColumnInfo#TEXT() = 2` Column affinity constant for strings. | Cmn |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/room3/ColumnInfo#UNDEFINED() = 1` Undefined type affinity. | Cmn |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/room3/ColumnInfo#UNICODE() = 6` Collation sequence that uses Unicode Collation Algorithm. | Cmn |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/room3/ColumnInfo#UNSPECIFIED() = 1` Collation sequence is not specified. | Cmn |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/room3/ColumnInfo#VALUE_UNSPECIFIED()` A constant for `https://developer.android.com/reference/kotlin/androidx/room3/ColumnInfo#defaultValue()` that makes the column to have no default value. | Cmn |

| ### Public constructors |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/room3/ColumnInfo#ColumnInfo(kotlin.String,kotlin.Int,kotlin.Boolean,kotlin.Int,kotlin.String)( name: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, typeAffinity: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html, collate: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, defaultValue: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html )` | Cmn |

| ### Public properties |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/room3/ColumnInfo#collate()` The collation sequence for the column, which will be used when constructing the database. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/room3/ColumnInfo#defaultValue()` The default value for this column. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/room3/ColumnInfo#index()` Convenience value to index the property. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/room3/ColumnInfo#name()` Name of the column in the database. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/room3/ColumnInfo#typeAffinity()` The type affinity for the column, which will be used when constructing the database. | Cmn |

## Constants

### BINARY

Cmn Added in [3.0.0](https://developer.android.com/jetpack/androidx/releases/room3#3.0.0)

```
const val BINARY = 2: Int
```

Collation sequence for case-sensitive match.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/room3/ColumnInfo#collate()` |   |

### BLOB

Cmn Added in [3.0.0](https://developer.android.com/jetpack/androidx/releases/room3#3.0.0)

```
const val BLOB = 5: Int
```

Column affinity constant for binary data.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/room3/ColumnInfo#typeAffinity()` |   |

### INHERIT_FIELD_NAME

Cmn Added in [3.0.0](https://developer.android.com/jetpack/androidx/releases/room3#3.0.0)

```
const val INHERIT_FIELD_NAME: String
```

Constant to let Room inherit the property name as the column name. If used, Room will use the property name as the column name.

### INTEGER

Cmn Added in [3.0.0](https://developer.android.com/jetpack/androidx/releases/room3#3.0.0)

```
const val INTEGER = 3: Int
```

Column affinity constant for integers or booleans.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/room3/ColumnInfo#typeAffinity()` |   |

### LOCALIZED

Cmn Added in [3.0.0](https://developer.android.com/jetpack/androidx/releases/room3#3.0.0)

```
const val LOCALIZED = 5: Int
```

Collation sequence that uses system's current locale.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/room3/ColumnInfo#collate()` |   |

### NOCASE

Cmn Added in [3.0.0](https://developer.android.com/jetpack/androidx/releases/room3#3.0.0)

```
const val NOCASE = 3: Int
```

Collation sequence for case-insensitive match.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/room3/ColumnInfo#collate()` |   |

### REAL

Cmn Added in [3.0.0](https://developer.android.com/jetpack/androidx/releases/room3#3.0.0)

```
const val REAL = 4: Int
```

Column affinity constant for floats or doubles.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/room3/ColumnInfo#typeAffinity()` |   |

### RTRIM

Cmn Added in [3.0.0](https://developer.android.com/jetpack/androidx/releases/room3#3.0.0)

```
const val RTRIM = 4: Int
```

Collation sequence for case-sensitive match except that trailing space characters are ignored.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/room3/ColumnInfo#collate()` |   |

### TEXT

Cmn Added in [3.0.0](https://developer.android.com/jetpack/androidx/releases/room3#3.0.0)

```
const val TEXT = 2: Int
```

Column affinity constant for strings.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/room3/ColumnInfo#typeAffinity()` | () |

### UNDEFINED

Cmn Added in [3.0.0](https://developer.android.com/jetpack/androidx/releases/room3#3.0.0)

```
const val UNDEFINED = 1: Int
```

Undefined type affinity. Will be resolved based on the type.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/room3/ColumnInfo#typeAffinity()` |   |

### UNICODE

Cmn Added in [3.0.0](https://developer.android.com/jetpack/androidx/releases/room3#3.0.0)

```
const val UNICODE = 6: Int
```

Collation sequence that uses Unicode Collation Algorithm.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/room3/ColumnInfo#collate()` |   |

### UNSPECIFIED

Cmn Added in [3.0.0](https://developer.android.com/jetpack/androidx/releases/room3#3.0.0)

```
const val UNSPECIFIED = 1: Int
```

Collation sequence is not specified. The match will behave like `https://developer.android.com/reference/kotlin/androidx/room3/ColumnInfo#BINARY()`.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/room3/ColumnInfo#collate()` |   |

### VALUE_UNSPECIFIED

Cmn Added in [3.0.0](https://developer.android.com/jetpack/androidx/releases/room3#3.0.0)

```
const val VALUE_UNSPECIFIED: String
```

A constant for `https://developer.android.com/reference/kotlin/androidx/room3/ColumnInfo#defaultValue()` that makes the column to have no default value.

## Public constructors

### ColumnInfo

Cmn Added in [3.0.0](https://developer.android.com/jetpack/androidx/releases/room3#3.0.0)

```
ColumnInfo(
    name: String = INHERIT_FIELD_NAME,
    typeAffinity: Int = UNDEFINED,
    index: Boolean = false,
    collate: Int = UNSPECIFIED,
    defaultValue: String = VALUE_UNSPECIFIED
)
```

## Public properties

### collate

Cmn

```
val collate: Int
```

The collation sequence for the column, which will be used when constructing the database.

The default value is `https://developer.android.com/reference/kotlin/androidx/room3/ColumnInfo#UNSPECIFIED()`. In that case, Room does not add any collation sequence to the column, and SQLite treats it like `https://developer.android.com/reference/kotlin/androidx/room3/ColumnInfo#BINARY()`.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The collation sequence of the column. This is either `https://developer.android.com/reference/kotlin/androidx/room3/ColumnInfo#UNSPECIFIED()`, `https://developer.android.com/reference/kotlin/androidx/room3/ColumnInfo#BINARY()`, `https://developer.android.com/reference/kotlin/androidx/room3/ColumnInfo#NOCASE()`, `https://developer.android.com/reference/kotlin/androidx/room3/ColumnInfo#RTRIM()`, `https://developer.android.com/reference/kotlin/androidx/room3/ColumnInfo#LOCALIZED()` or `https://developer.android.com/reference/kotlin/androidx/room3/ColumnInfo#UNICODE()`. |

### defaultValue

Cmn

```
val defaultValue: String
```

The default value for this column.

```kotlin
@ColumnInfo(defaultValue = "No name")
public name: String

@ColumnInfo(defaultValue = "0")
public flag: Int
```

Note that the default value you specify here will *NOT* be used if you simply insert the `https://developer.android.com/reference/kotlin/androidx/room3/Entity` with `https://developer.android.com/reference/kotlin/androidx/room3/Insert`. In that case, the value of the object at runtime will be used. Use `https://developer.android.com/reference/kotlin/androidx/room3/Query` with an `INSERT` statement and skip this column in the statement in order to use this default value. Alternative, if a 'partial entity' is used as parameter of the `https://developer.android.com/reference/kotlin/androidx/room3/Insert` along with specifying the target entity via `https://developer.android.com/reference/kotlin/androidx/room3/Insert#entity()`, the default value will be used if the data object class of the parameter does not define a property for this column.

`NULL`, `CURRENT_TIMESTAMP` and other SQLite constant values are interpreted as such. If you want to use them as strings for some reason, surround them with single-quotes.

```kotlin
@ColumnInfo(defaultValue = "NULL")
public description: String?

@ColumnInfo(defaultValue = "'NULL'")
public name: String
```

You can also use constant expressions by surrounding them with parentheses.

```kotlin
@ColumnInfo(defaultValue = "('Created at' || CURRENT_TIMESTAMP)")
public notice: String
```

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | The default value for this column. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/room3/ColumnInfo#VALUE_UNSPECIFIED()` |   |

### index

Cmn

```
val index: Boolean
```

Convenience value to index the property.

If you would like to create a composite index instead use the `https://developer.android.com/reference/kotlin/androidx/room3` annotation.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | True if this property should be indexed, false otherwise. Defaults to false. |

### name

Cmn

```
val name: String
```

Name of the column in the database. Defaults to the property name if not set.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | Name of the column in the database. |

### typeAffinity

Cmn

```
val typeAffinity: Int
```

The type affinity for the column, which will be used when constructing the database.

If it is not specified, the value defaults to `https://developer.android.com/reference/kotlin/androidx/room3/ColumnInfo#UNDEFINED()` and Room resolves it based on the property's type and available `https://developer.android.com/reference/kotlin/androidx/room3/ColumnTypeConverters`.

See [SQLite types documentation](https://www.sqlite.org/datatype3.html) for details.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The type affinity of the column. This is either `https://developer.android.com/reference/kotlin/androidx/room3/ColumnInfo#UNDEFINED()`, `https://developer.android.com/reference/kotlin/androidx/room3/ColumnInfo#TEXT()`, `https://developer.android.com/reference/kotlin/androidx/room3/ColumnInfo#INTEGER()`, `https://developer.android.com/reference/kotlin/androidx/room3/ColumnInfo#REAL()`, or `https://developer.android.com/reference/kotlin/androidx/room3/ColumnInfo#BLOB()`. |