apps/docs/content/docs/orm/reference/database-features.mdx
This page gives an overview of the features which are provided by the databases that Prisma ORM supports. Additionally, it explains how each of these features can be used in Prisma ORM with pointers to further documentation.
This section describes which database features exist on the relational databases that are currently supported by Prisma ORM. The Prisma schema column indicates how a certain feature can be represented in the Prisma schema and links to its documentation. Note that database features can be used in Prisma Client even though they might not yet be representable in the Prisma schema.
:::note
These features are only for relational databases. Supported features for NoSQL databases, like MongoDB, can be found below.
:::
| Constraint | Supported | Prisma schema | Prisma Client | Prisma Migrate |
|---|---|---|---|---|
PRIMARY KEY | ✔️ | @id and @@id | ✔️ | ✔️ |
FOREIGN KEY | ✔️ | Relation fields | ✔️ | ✔️ |
UNIQUE | ✔️* | @unique and @@unique | ✔️ | ✔️ |
CHECK | ✔️† | Not yet | ✔️ | Not yet |
NOT NULL | ✔️ | ? | ✔️ | ✔️ |
DEFAULT | ✔️ | @default | ✔️ | ✔️ |
EXCLUDE | ✔️‡ | Not yet | ✔️ | Not yet |
* Caveats apply when using the
UNIQUEconstraint with Microsoft SQL Server † Only supported in MySQL in version 8 and higher. ‡ Only supported in PostgreSQL.
| Deletion behavior | Supported | Prisma schema | Prisma Client | Prisma Migrate |
|---|---|---|---|---|
CASCADE | ✔️ | ✔️ | ✔️ | ✔️ |
RESTRICT | ✔️* | ✔️ | ✔️ | ✔️ |
NO ACTION | ✔️ | ✔️ | ✔️ | ✔️ |
SET DEFAULT | ✔️ | ✔️ | ✔️ | ✔️ |
SET NULL | ✔️ | ✔️ | ✔️ | ✔️ |
*
RESTRICTis not supported in Microsoft SQL Server.
| Index | Supported | Prisma schema | Prisma Client | Prisma Migrate |
|---|---|---|---|---|
UNIQUE | ✔️ | @unique and @@unique | ✔️ | ✔️ |
USING | PostgreSQL only | type | ✔️ | ✔️ |
WHERE | ✔️ | where (Preview) | ✔️ | ✔️ |
(expression) | ✔️ | Not yet | ✔️ | Not yet |
INCLUDE | PostgreSQL and Microsoft SQL Server only | Not yet | ✔️ | Not yet |
Algorithm specified via USING:
| Index type (Algorithm) | Supported | Prisma schema | Prisma Client | Prisma Migrate |
|---|---|---|---|---|
| B-tree | ✔️ | ✔️† | ✔️ | Not yet |
| Hash | ✔️ | ✔️† | ✔️ | Not yet |
| GiST | ✔️* | ✔️† | ✔️* | Not yet |
| GIN | ✔️* | ✔️† | ✔️* | Not yet |
| BRIN | ✔️* | ✔️† | ✔️* | Not yet |
| SP-GiST | ✔️* | ✔️† | ✔️* | Not yet |
4.0.0 and later.| Feature | Supported | Prisma schema | Prisma Client | Prisma Migrate |
|---|---|---|---|---|
| Autoincrementing IDs | ✔️ | autoincrement() | ✔️ | ✔️ |
| Arrays | PostgreSQL only | [] | ✔️ | ✔️ |
| Enums | ✔️*† | enum | ✔️ | ✔️ |
| Native database types | ✔️ | ✔️ | ✔️ | Not yet |
| SQL Views | ✔️ | Not yet | Not yet | Not yet |
| JSON support | ✔️† | ✔️ | ✔️ | ✔️ |
| Fuzzy/Phrase full text search | ✔️‡ | Not yet | Not yet | Not yet |
| Table inheritance | PostgreSQL and Microsoft SQL Server only | Not yet | ✔️ | Not yet |
| Authorization and user management | ✔️‡ | Not yet | Not yet | Not yet |
This section describes which database features exist on the NoSQL databases that are currently supported by Prisma ORM.
The following table lists common MongoDB features and describes the level of support offered by Prisma ORM:
| Feature | Supported by Prisma ORM | Notes |
|---|---|---|
| Embedded documents | ✔️ | |
| Transactions | ✔️ | |
| Indexes | ✔️ with caveats | Indexes can only be introspected if the field they refer to includes at least some data. |
| Autoincrementing IDs | No | |
| Compound IDs | No | MongoDB does not support composite IDs (@@id) |
Generated ObjectId | ✔️ | See: Defining IDs for MongoDB |
| Arrays | ✔️ | |
| Enums | ✔️ | Implemented at Prisma ORM level |
| Native database types | ✔️ | See: Field mapping reference |
| JSON support | ✔️ | Advanced Json field filtering is not yet supported. |
| DBrefs | No | |
| Change streams | No | |
| Direct access to the aggregation pipeline | No |