The following type mappings apply when you enable nativeTypes Preview.

String

Variable length text.

PostgreSQL connector

The following table lists the PostgreSQL native database types that map to Prisma's String scalar type:

Native database typeNative database type attributeNotes
text@db.Text⭐ Prisma Migrate default native type for String
char@db.Char(x)
varchar@db.VarChar(n)
bit@db.Bit
varbit@db.VarBit
uuid@db.Uuid
xml@db.Xml
model Sample {
text String @db.Text
char String @db.Char(22)
varchar String @db.VarChar(100)
bit String @db.Bit
varbit String @db.VarBit
uuid String @db.Uuid
}

MySQL connector

The following table lists the MySQL native database types that map to Prisma's String scalar type:

Native database typeNative database type attributeNotes
VARCHAR@db.VarChar(X)
  • ⭐ Prisma Migrate default native type for String.
  • Default length (X) is 191.
TEXT@db.Text
CHAR@db.Char(X)
TINYTEXT@db.TinyText
MEDIUMTEXT@db.MediumText
LONGTEXT@db.LongText
model Sample {
varchar String @db.VarChar(100)
text String @db.Text
char String @db.Char(20)
tinyText String @db.TinyText
mediumText String @db.MediumText
longText String @db.LongText
}

SQL Server connector

The following table lists the SQL Server native database types that map to Prisma's String scalar type:

Native database typeNative database type attributeNotes
char@db.Char(X)
nchar@db.NChar(X)
varchar@db.VarChar(X)
nvarchar@db.NVarChar(X)
  • ⭐ Prisma Migrate default native type for String
  • Default length (X) is 1000.
text@db.Text
ntext@db.NText
xml@db.Xml
model Sample {
char String @db.Char(20)
nchar String @db.NChar(40)
varchar String @db.VarChar(189)
nvarchar String @db.NVarChar(100)
// Also accept 'Max'
max_varchar String @db.VarChar(Max)
max_nvarchar String @db.NVarChar(Max)
ntext String @db.NText
text String @db.Text
xml String @db.Xml
}

SQLite connector

TEXT

Raw JSON

string

Clients

Prisma Client JS
string

Boolean

True or false value.

PostgreSQL connector

The following table lists the PostgreSQL native database types that map to Prisma's Boolean scalar type:

Native database typesNative database type attributeNotes
boolean@db.Boolean
model Sample {
bool Boolean @db.boolean
}

MySQL connector

The following table lists the MySQL native database types that map to Prisma's Boolean scalar type:

Native database typesNative database type attributeNotes
TINYINT(1)@db.TinyInt
  • TINYINT maps to Int if the max length is greater than 1 (for example, TINYINT(2)) or the default value is anything other than 1, 0, or NULL
  • Aliases: BOOLEAN, BOOL
model Sample {
bool Boolean @db.TinyInt
}

SQL Server connector

The following table lists the SQL Server native database types that map to Prisma's Boolean scalar type:

Native database typesNative database type attributeNotes
bit@db.Bit
model Sample {
bit Boolean @db.Bit
}

SQLite connector

INTEGER

Raw JSON

boolean

Clients

Prisma Client JS
boolean

Int

PostgreSQL connector

The following table lists the PostgreSQL native database types that map to Prisma's Int scalar type:

Native database typesNative database type attributeNotes
integer@db.Integer
  • ⭐ Prisma Migrate default native type for Int.
  • @db.Int @default(autoincrement()) is equivalent to serial4
  • Aliases: int, int4, serial4
smallint@db.SmallInt
  • Aliases: int2, serial2
model Sample {
integer Int @db.Integer
smallint Int @db.SmallInt
}

MySQL connector

The following table lists the MySQL native database types that map to Prisma's Int scalar type:

Native database typesNative database type attributeNotes
INT@db.Int⭐ Prisma Migrate default native type for Int.
SMALLINT@db.SmallInt
MEDIUMINT@db.MediumInt
YEAR@db.Year
TINYINT@db.TinyIntTINYINT maps to Int if the max lenght is greater than 1 (for example, TINYINT(2)) or the default value is anything other than 1, 0, or NULL

SQL Server connector

The following table lists the SQL Server native database types that map to Prisma's Int scalar type:

Native database typesNative database type attributeNotes
int@db.Int⭐ Prisma Migrate default native type for Int.
smallint@db.SmallInt
tinyint@db.TinyInt
model Sample {
int Int @db.Int
smallint Int @db.SmallInt
tinyint Int @db.TinyInt
}

Clients

Prisma Client JS
number

BigInt

Note: BigInt is a new Prisma type in 2.11.0 and is only available if you enable the nativeTypes Preview feature.

PostgreSQL connector

The following table lists the PostgreSQL native database types that map to Prisma's BigInt scalar type:

Native database typesNative database type attributeNotes
bigint@db.BigInt
  • Aliases: int8, serial8, bigserial
model Sample {
bigInt BigInt @db.BigInt
}

MySQL connector

The following table lists the MySQL native database types that map to Prisma's BigInt scalar type:

Native database typesNative database type attributeNotes
BIGINT@db.BigInt
  • * bigint maps to Int if the nativeTypes Preview is not enabled.

SQL Server connector

The following table lists the SQL Server native database types that map to Prisma's BigInt scalar type:

Native database typesNative database type attributeNotes
bigint@db.BigInt
model Sample {
bigInt BigInt @db.BigInt
}

Clients

Prisma Client JS
BigInt

Decimal

Note: Decimal is a new Prisma type in 2.11.0 and is only available if you enable the nativeTypes Preview feature.

PostgreSQL connector

The following table lists the PostgreSQL native database types that map to Prisma's Decimal scalar type:

Native database typesNative database type attributeNotes
decimal@db.Decimal(X, Y)
  • Default size (X, Y) is 2, 2.
  • Aliases: numeric
model Sample {
decimal Decimal @db.Decimal(2,2)
}

MySQL connector

The following table lists the MySQL native database types that map to Prisma's Decimal scalar type:

Native database typesNative database type attributeNotes
DECIMAL@db.Decimal(X, Y)
  • Aliases: numeric
model Sample {
decimal Decimal @db.Decimal(2,2)
}

SQL Server connector

The following table lists the SQL Server native database types that map to Prisma's Decimal scalar type:

Native database typesNative database type attributeNotes
decimal | numeric@db.Decimal(X, Y)
  • Aliases: numeric
model Sample {
decimal Decimal @db.Decimal(2,2)
max_decimal Decimal @db.Decimal(18,0)
}

Clients

Prisma Client JS
Decimal

Float

Floating point number.

PostgreSQL connector

The following table lists the PostgreSQL native database types that map to Prisma's Float scalar type:

Native database typesNative database type attributeNotes
real@db.Real
doubleprecision@db.DoublePrecision

Note: Float currently migrates to Decimal(65,30). This will change in a later release.

MySQL connector

The following table lists the MySQL native database types that map to Prisma's Float scalar type:

Native database typesNative database type attribute
FLOAT@db.Float
DOUBLE@db.Double

Note: Float currently migrates to Decimal(65,30). This will change in a later release.

SQL Server connector

The following table lists the SQL Server native database types that map to Prisma's Float scalar type:

Native database typesNative database type attribute
float@db.Float
money@db.Money
smallmoney@db.SmallMoney
real@db.Real

Note: Float currently migrates to Decimal(32,16). This will change in a later release.

model Sample {
money Float @db.Money
smallmoney Float @db.SmallMoney
real Float @db.Real
float Float @db.Float(53)
}

Clients

Prisma Client JS
number

DateTime

  • Prisma Client returns all DateTime as ISO 8601-formatted strings.

PostgreSQL connector

The following table lists the PostgreSQL native database types that map to Prisma's DateTime scalar type:

Native database typesNative database type attributeNotes
timestamp*@db.Timestamp(x)
  • ⭐ Prisma Migrate default native type for DateTime.
  • Default value is timestamp(3)
date@db.Date
time@db.Time(x)

MySQL connector

The following table lists the MySQL native database types that map to Prisma's DateTime scalar type:

Native database typesNative database type attributeNotes
DATETIME(x)*@db.DateTime(x)
  • ⭐ Prisma Migrate default native type for DateTime.
  • Default value is DateTime(3)
DATE@db.Date
TIME(x)@db.Time(x)
TIMESTAMP@db.Timestamp

You can also use MySQL's YEAR type with Int:

yearField Int @db.Year

SQL Server connector

The following table lists the SQL Server native database types that map to Prisma's DateTime scalar type:

Native database typesNative database type attributeNotes
date@db.Date
time@db.Time
datetime@db.DateTime
datetime2@db.DateTime2
  • ⭐ Prisma Migrate default native type for DateTime.
model Sample {
date DateTime @db.Date
time DateTime @db.Time
datetime DateTime @db.DateTime
datetime2 DateTime @db.DateTime2
}

Clients

Prisma Client JS
Date

Json

A JSON object.

Connectors

PostgreSQL connector

The following table lists the PostgreSQL native database types that map to Prisma's Json scalar type:

Native database typesNative database type attributeNotes
json@db.Json
jsonb@db.JsonB
  • ⭐ Prisma Migrate default native type for Json.
model Sample {
json Json @db.Json
json Json @db.JsonB
}

MySQL connector

The following table lists the MySQL native database types that map to Prisma's Json scalar type:

Native database typesNative database type attributeNotes
JSON@db.Json
model Sample {
json Json @db.Json
}

SQL Server connector

SQL Server does not have a specific data type for JSON - however, there are a number of built-in functions for reading and modifying JSON.

Native database typesNative database type attribute
JSON@db.NVarChar(1000)

Clients

Prisma Client JS
object

Bytes

Note: Bytes is a new Prisma type in 2.11.0 and is only available if you enable the nativeTypes Preview feature.

PostgreSQL connector

The following table lists the PostgreSQL native database types that map to Prisma's Bytes scalar type:

Native database typesNative database type attribute
bytea@db.ByteA
model sample {
bit Bytes @db.ByteA
}

MySQL connector

The following table lists the MySQL native database types that map to Prisma's Bytes scalar type:

Native database typesNative database type attributeNotes
LONGBLOB@db.LongBlob
  • ⭐ Prisma Migrate default native type for Bytes.
BINARY@db.Binary
VARBINARY@db.VarBinary
TINYBLOB@db.TinyBlob
BLOB@db.Blob
MEDIUMBLOB@db.MediumBlob
BIT@db.Bit
model sample {
bit Bytes @db.Bit(8)
bin Bytes @db.Binary(4)
vBin Bytes @db.VarBinary(5)
blob Bytes @db.Blob
tBlob Bytes @db.TinyBlob
mBlob Bytes @db.MediumBlob
lBlob Bytes @db.LongBlob
}

SQL Server connector

The following table lists the SQL Server native database types that map to Prisma's Bytes scalar type:

Native database typesNative database type attributeNotes
binary@db.Binary
varbinary@db.VarBinary
  • ⭐ Prisma Migrate default native type for DateTime.
  • Default value is varbinary(max)
image@db.Image
model Sample {
binary Bytes @db.Binary(230)
varbinary Bytes @db.VarBinary(150)
image Bytes @db.Image
// Max value
max_varbinary Bytes @db.VarBinary(Max)
}

Clients

Prisma Client JS
Buffer

Prisma Migrate default native types

If you do not add a native database type attribute to a field, Prisma Migrate uses a default native database type. The following example does not include a type attribute:

model User [
name String // No type attribute
]

If you are using Postgres, String maps to text by default. To change the default, add a type attribute - the following example specifies that name should be @db.VarChar(90):

model User [
name String @db.VarChar(90)
]
Edit this page on GitHub