---
title: "Introspecting Databases"
description: "Database introspection inspects an existing database structure and automatically generates corresponding TypeScript schema and relation code for your project. This saves you from writing schema def..."
last_updated: "2026-10-12T08:15:21.997781+00:00"
canonical_url: "https://www.doc0.dev/docs/e1b68fed-3c4e-4c95-b2ba-ebf050f78025/guide/how-to-guides/introspecting-databases"
---

## Overview

Database introspection inspects an existing database structure and automatically generates corresponding TypeScript schema and relation code for your project. This saves you from writing schema definitions by hand when working with an already established database.

> [!NOTE]
> Introspection analyzes your database tables, columns, constraints, and relationships to produce TypeScript files ready for use in your application.

## How It Works

When you run an introspection command, the system connects to your database, reads the system catalog and information schema, and compiles the layout into TypeScript code. 

```mermaid
flowchart TD
    A[Connect to existing database] --> B[Analyze tables, columns & constraints]
    B --> C[Generate TypeScript schema code]
    C --> D[Save schema files to project output directory]
```

## Supported Database Dialects

Introspection supports multiple database providers and dialects. Supported dialects: `postgresql`, `mysql`, `sqlite`, `turso`, `singlestore`, `gel`.

*(Sources: `drizzle-kit/src/cli/schema.ts`)*

## Outputs

Depending on the database dialect and configuration, introspection typically generates:
* **Schema file (`schema.ts`)**: Contains table definitions, columns, data types, and constraints.
* **Relations file (`relations.ts`)**: Contains table relationships when applicable.

> [!TIP]
> If your project already contains migration history snapshots, introspection will recognize them and avoid duplicating migration files.

## Related

- [Declaring Schemas](https://www.doc0.dev/docs/e1b68fed-3c4e-4c95-b2ba-ebf050f78025/guide/core-features/declaring-schemas)
- [Configuring Drizzle Kit](https://www.doc0.dev/docs/e1b68fed-3c4e-4c95-b2ba-ebf050f78025/guide/configuration/configuring-drizzle-kit)


## Sitemap

See the full [sitemap](https://www.doc0.dev/docs/e1b68fed-3c4e-4c95-b2ba-ebf050f78025/llms.txt) for all pages in this wiki.
