Cloudflare D1 icon

Cloudflare D1

Execute operations against Cloudflare D1 serverless databases. Supports structured operations (Insert, Select, Update, Delete), raw SQL queries, and can be used as a tool by AI Agents.

Table Management → Create Table

AI-generated

Summary

Create a new table with defined columns and optional constraints.

Inputs

  • databaseId (required) — The unique identifier of the Cloudflare D1 database to operate on.
  • createTableName (required) — The name of the new table to be created.
  • columns (required) — A collection of column definitions, each specifying name, type, primary key, auto‑increment, nullability, etc.
  • createTableOptions — Optional table creation options such as IF NOT EXISTS, ROWID setting, and strict mode.

Output shape

A confirmation object containing success status, the created table name, and any meta information about the operation.

The response is returned as part of the standard n8n result envelope; it typically includes success flag and metadata but does not return the full DDL statement.

Examples

Example 1: Create a users table with id, email, and timestamps.

Database ID: 12345, Table Name: users, Columns: [{name: "id", type: "INTEGER", primaryKey: true, autoIncrement: true}], Options: {ifNotExists: true}

Example 2: Create a posts table with strict typing and without rowid.

Database ID: myDB, Table Name: posts, Columns: [{name: "id", type: "INTEGER", primaryKey: true, autoIncrement: false}], Options: {withoutRowId: true, strict: true}

Example 3: Create a logs table only if it does not already exist.

Database ID: logsDB, Table Name: error_log, Columns: [{name: "message", type: "TEXT", notNull: true}], Options: {ifNotExists: true}

Discussion