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 attribute (Preview)Introspection
text (default type)@db.Text✔️
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 attributeIntrospection
VARCHAR (default type)@db.VarChar(191)✔️
TEXT@db.Text✔️
CHAR@db.Char✔️
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 attribute (Preview)Introspection
char (default type)@db.Char✔️
nchar@db.NChar✔️
varchar@db.VarChar✔️
nvarchar@db.NVarChar✔️
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 attribute (Preview)Introspection
boolean (default)@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 types (type | aliases)Native database type attribute (Preview)Introspection
TINYINT(1)* | BOOLEAN, BOOL (default)@db.TinyInt✔️

* TINYINT 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

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 attribute (Preview)Introspection
bit (default)@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 attribute (preview)Introspection
integer (default type) | int, int4@db.Integer✔️
smallint | int2@db.SmallInt✔️
serial | serial4@db.Serial✔️
smallserial | serial2@db.SmallSerial✔️
bigserial | serial8@db.BigSerial✔️
model Sample {
integer Int @db.Integer
smallint Int @db.SmallInt
serial Int @db.Serial
smallserial Int @db.SmallSerial
bigserial Int @db.BigSerial
}

MySQL connector

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

Native database typesNative database type attribute (Preview)Introspection
INT (default type)@db.Int✔️
SMALLINT@db.SmallInt✔️
MEDIUMINT@db.MediumInt✔️
YEAR@db.Year✔️
TINYINT*@db.TinyInt✔️
  • * TINYINT 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 attribute (preview)Introspection
int@db.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 attribute (preview)Introspection
bigint (default type)@db.BigInt✔️
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 attribute (preview)Introspection
BIGINT (default type)@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 attribute (preview)Introspection
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 attributeIntrospection
decimal (default type)@db.Decimal✔️
numeric@db.Numeric✔️
model Sample {
decimal Decimal @db.Decimal(2,2)
numeric Decimal @db.Numeric(1,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 attributeIntrospection
DECIMAL (default type)@db.Decimal✔️
NUMERIC@db.Numeric✔️
model Sample {
decimal Decimal @db.Decimal(2,2)
numeric Decimal @db.Numeric(1,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 attributeIntrospection
decimal@db.Decimal✔️
numeric@db.Numeric✔️
model Sample {
decimal Decimal @db.Decimal(2,2)
numeric Decimal @db.Numeric(1,2)
max_decimal Decimal @db.Decimal(18,0)
max_numeric Decimal @db.Numeric(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 attributeIntrospection
real@db.Real✔️
doubleprecision@db.DoublePrecision✔️

MySQL connector

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

Native database typesNative database type attributeIntrospection
FLOAT@db.Float✔️
DOUBLE@db.Double✔️

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 attributeIntrospection
float@db.Float✔️
money@db.Money✔️
smallmoney@db.SmallMoney✔️
real@db.Real✔️
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 attribute (Preview)Introspection
timestamp* (default)@db.Timestamp(x)✔️
date@db.Date✔️
time@db.Time(x)✔️
  • * timestamp(3) by default

MySQL connector

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

Native database typesNative database type attribute (Preview)Introspection
DATETIME(x)* (default type)N/A✔️
DATE@db.Date✔️
TIME(x)@db.Time(x)✔️
TIMESTAMP@db.Timestamp✔️
  • * DATETIME(3) by default

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 attribute (Preview)Introspection
date@db.Date✔️
time@db.Time✔️
datetime@db.DateTime✔️
datetime2@db.DateTime2✔️
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 attribute (Preview)Introspection
json (default)@db.Json✔️
jsonb@db.JsonB✔️
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 attribute (Preview)Introspection
JSON (default type)@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.

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 (Preview)Introspection
bytea (default)@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 attribute (Preview)Introspection
LONGBLOB (default type)@db.LongBlob✔️
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 attribute (Preview)Introspection
binary@db.Binary✔️
varbinary@db.VarBinary✔️
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
Edit this page on GitHub