# What SQL Dialects Are Supported for Export in drawDB?

> DrawDB exports to six SQL dialects: MySQL PostgreSQL SQLite MariaDB MS SQL Server and Oracle SQL. Generate basic SQL with our utilities.

- Repository: [drawDB/drawdb](https://github.com/drawdb-io/drawdb)
- Tags: api-reference
- Published: 2026-08-14

---

**drawDB supports export to six SQL dialects:** MySQL, PostgreSQL, SQLite, MariaDB, Microsoft SQL Server, and Oracle SQL, plus generic helper utilities for basic SQL generation.

drawDB is an open-source database design tool that converts visual entity-relationship diagrams into executable SQL scripts. The export system routes your diagram to a dialect-specific code generator based on the `database` property selected for your project.

## How drawDB Routes Exports to SQL Dialects

The core dispatch logic lives in **[`src/utils/exportSQL/index.js`](https://github.com/drawdb-io/drawdb/blob/main/src/utils/exportSQL/index.js)**. This module inspects `diagram.database`—a constant from **[`src/data/constants.js`](https://github.com/drawdb-io/drawdb/blob/main/src/data/constants.js)**—and delegates to the appropriate exporter implementation.

The `DB` enum in [`constants.js`](https://github.com/drawdb-io/drawdb/blob/main/constants.js) defines the supported targets:

```javascript
// From src/data/constants.js
export const DB = Object.freeze({
  MYSQL: 'mysql',
  POSTGRES: 'postgres',
  SQLITE: 'sqlite',
  MARIADB: 'mariadb',
  MSSQL: 'mssql',
  ORACLE: 'oracle'
});

```

When you call `exportSQL(diagram)`, the dispatcher matches `diagram.database` against these values and loads the corresponding module.

## MySQL Export

**[`src/utils/exportSQL/mysql.js`](https://github.com/drawdb-io/drawdb/blob/main/src/utils/exportSQL/mysql.js)** generates MySQL-compatible `CREATE TABLE` statements with full support for:

- `AUTO_INCREMENT` for primary keys
- `UNSIGNED` numeric modifiers
- Backtick-quoted identifiers
- MySQL-specific data type mappings

```javascript
import { exportSQL } from "./src/utils/exportSQL";
import { DB } from "./src/data/constants";

const mysqlDiagram = { /* tables, fields, relationships */, database: DB.MYSQL };
const mysqlSQL = exportSQL(mysqlDiagram);
// Returns: "CREATE TABLE `users` (`id` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, ...);"

```

## PostgreSQL Export

**[`src/utils/exportSQL/postgres.js`](https://github.com/drawdb-io/drawdb/blob/main/src/utils/exportSQL/postgres.js)** produces PostgreSQL syntax featuring:

- `GENERATED BY DEFAULT AS IDENTITY` for auto-incrementing keys
- `CHECK` constraints
- Double-quoted identifiers for case sensitivity
- Native PostgreSQL type mappings (e.g., `SERIAL`, `TIMESTAMPTZ`)

```javascript
const pgDiagram = { /* diagram data */, database: DB.POSTGRES };
const pgSQL = exportSQL(pgDiagram);
// Returns: 'CREATE TABLE "users" ("id" INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, ...);'

```

## SQLite Export

**[`src/utils/exportSQL/sqlite.js`](https://github.com/drawdb-io/drawdb/blob/main/src/utils/exportSQL/sqlite.js)** handles SQLite's unique requirements:

- `AUTOINCREMENT` (SQLite's specific spelling, no underscore)
- Double-quoted identifiers per SQLite's flexible quoting rules
- Simplified type system mapping

```javascript
const sqliteDiagram = { /* diagram data */, database: DB.SQLITE };
const sqliteSQL = exportSQL(sqliteDiagram);
// Returns: 'CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT, ...);'

```

## MariaDB Export

**[`src/utils/exportSQL/mariadb.js`](https://github.com/drawdb-io/drawdb/blob/main/src/utils/exportSQL/mariadb.js)** extends MySQL syntax with MariaDB-specific adaptations. While structurally similar to the MySQL exporter, this module accounts for MariaDB's divergent features and defaults, ensuring compatibility with both community and enterprise MariaDB releases.

## Microsoft SQL Server Export

**[`src/utils/exportSQL/mssql.js`](https://github.com/drawdb-io/drawdb/blob/main/src/utils/exportSQL/mssql.js)** generates T-SQL code with:

- Bracketed identifiers `[like_this]`
- `IDENTITY(1,1)` for auto-incrementing columns
- SQL Server-specific type mappings (e.g., `NVARCHAR`, `DATETIME2`)

```javascript
const mssqlDiagram = { /* diagram data */, database: DB.MSSQL };
const mssqlSQL = exportSQL(mssqlDiagram);
// Returns: "CREATE TABLE [users] ([id] INT IDENTITY(1,1) PRIMARY KEY, ...);"

```

## Oracle SQL Export

**[`src/utils/exportSQL/oraclesql.js`](https://github.com/drawdb-io/drawdb/blob/main/src/utils/exportSQL/oraclesql.js)** handles Oracle's distinct SQL dialect including:

- Oracle-specific data types (`NUMBER`, `VARCHAR2`)
- Sequence and trigger patterns for auto-increment behavior
- Oracle's naming conventions and constraint syntax

## Generic SQL Helpers

**[`src/utils/exportSQL/generic.js`](https://github.com/drawdb-io/drawdb/blob/main/src/utils/exportSQL/generic.js)** provides shared utilities when no specific dialect is selected. This module contains base functions for:

- Type conversion and mapping
- Identifier quoting fallbacks
- Generic constraint generation

If `diagram.database` doesn't match any `DB` enum value, the dispatcher falls back to these helper functions for basic SQL output.

## Complete Export Code Example

Here's a practical pattern for programmatic export across dialects:

```javascript
import { exportSQL } from "./src/utils/exportSQL";
import { DB } from "./src/data/constants";

const diagram = {
  tables: [/* table definitions */],
  relationships: [/* foreign key definitions */],
  // database: DB.MYSQL | DB.POSTGRES | DB.SQLITE | DB.MARIADB | DB.MSSQL | DB.ORACLE
};

function exportToDialect(diagram, dialect) {
  const exportable = { ...diagram, database: dialect };
  return exportSQL(exportable);
}

// Example usage
const outputs = {
  mysql: exportToDialect(diagram, DB.MYSQL),
  postgres: exportToDialect(diagram, DB.POSTGRES),
  sqlite: exportToDialect(diagram, DB.SQLITE)
};

```

## Summary

- **Six dialects supported:** MySQL, PostgreSQL, SQLite, MariaDB, Microsoft SQL Server, and Oracle SQL via dedicated exporter modules in `src/utils/exportSQL/`
- **Dispatch architecture:** Central router in [`index.js`](https://github.com/drawdb-io/drawdb/blob/main/index.js) selects exporter based on `diagram.database` matching the `DB` enum
- **Dialect-specific features:** Each exporter handles native syntax for identifiers, auto-increment, types, and constraints
- **Fallback option:** Generic helper functions in [`generic.js`](https://github.com/drawdb-io/drawdb/blob/main/generic.js) provide basic SQL generation for unsupported cases

## Frequently Asked Questions

### Does drawDB support NoSQL database exports?

No. According to the drawDB source code, export is limited to relational SQL dialects. The `DB` enum in [`src/data/constants.js`](https://github.com/drawdb-io/drawdb/blob/main/src/data/constants.js) contains only SQL-based targets, and all exporter modules in `src/utils/exportSQL/` generate `CREATE TABLE` syntax.

### Can I export the same diagram to multiple SQL dialects?

Yes. The `exportSQL` function accepts any valid `diagram` object with a `database` property. You can clone your diagram, change only the `database` field to a different `DB` value, and re-export to generate dialect-specific scripts.

### How does drawDB handle auto-incrementing primary keys across dialects?

Each exporter implements the native syntax: `AUTO_INCREMENT` for MySQL/MariaDB, `GENERATED BY DEFAULT AS IDENTITY` for PostgreSQL, `AUTOINCREMENT` for SQLite, `IDENTITY(1,1)` for MSSQL, and sequences/triggers for Oracle.

### What happens if I select an unsupported database type?

The dispatcher in [`src/utils/exportSQL/index.js`](https://github.com/drawdb-io/drawdb/blob/main/src/utils/exportSQL/index.js) falls back to the generic helper functions from [`generic.js`](https://github.com/drawdb-io/drawdb/blob/main/generic.js). You'll receive basic SQL without dialect-specific optimizations, which may require manual adjustment to run on your target database.