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 → Select

AI-generated

Summary

Select rows from a Cloudflare D1 table with optional filtering, column projection, ordering, and limiting

Inputs

  • databaseId (required) — The ID of the Cloudflare D1 database to query
  • table (required) — The name or identifier of the table to select from
  • returnAll — Whether to return all results instead of respecting the limit
  • limit — Maximum number of rows to return when returnAll is false
  • columns — Array of column names or IDs to select; empty selects all columns
  • where — Array of condition objects, each with column, operator, and value for filtering
  • orderBy — Array of sort objects, each with column and direction for ordering results

Output shape

a list of selected records

Returns the matching rows; optionally limited by limit and can include only specified columns. The response includes a meta object with row count and may contain additional metadata, but the payload is the list of records.

Examples

Example 1: Retrieve up to 20 rows from the 'users' table

databaseId = abc123, table = users, limit = 20

Example 2: Select only 'id' and 'name' columns where 'status = active'

databaseId = abc123, table = users, columns = [{ "name": "id", "value": "id" }, { "name": "name", "value": "name" }], where = [{ "column": "status", "operator": "=", "value": "active" }]

Example 3: Fetch all rows from the 'orders' table with descending order on 'created_at'

databaseId = abc123, table = orders, returnAll = true, orderBy = [{ "column": "created_at", "direction": "DESC" }]

Discussion