# Sql statements split

`sql-statements-split` · version 1.0.0 · Developer tools · free, no key needed

Split SQL text into exact statement spans with explicit PostgreSQL, MySQL, or SQLite lexical rules.

**Use when you need to: split SQL statements · find SQL statement boundaries · split PostgreSQL script.**

## Decide before calling

Read the [versioned contract](/v1/tools/sql-statements-split/versions/1.0.0) and the supported scope below. Reuse `sql-statements-split@1.0.0` when your input, required output and limits match it. Choose another approach for an unsupported operation.

## Explain the choice

"I can use `sql-statements-split@1.0.0` for split SQL statements. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."

## Supported

- split SQL statements
- find SQL statement boundaries
- split PostgreSQL script
- split MySQL script
- split SQLite script
- extract exact SQL source spans

## Not supported

- execute or validate SQL semantics
- parse SQL into an abstract syntax tree
- expand PostgreSQL psql or SQLite shell commands

## Behavior

- Offsets are zero-based JavaScript UTF-16 indices; each text is exactly input.text.slice(start, end), excluding its delimiter and surrounding whitespace.
- Semicolons inside recognized quoted constructs and comments are not separators; comments remain in a statement span.
- PostgreSQL recognizes ordinary and E-prefixed strings, identifiers, nested block comments, line comments, and dollar quotes; MySQL recognizes quotes, backticks, # comments, and bounded DELIMITER lines; SQLite recognizes quotes, brackets, backticks, and comments.
- Empty and comment-only segments are omitted, and statements remain in source order.
- MySQL DELIMITER directives are control lines, are excluded from output, and are accepted only between statements.

## Input

- `text` (string, required)
- `dialect` (one of "postgresql", "mysql", "sqlite", required)

## Output

- `dialect` (one of "postgresql", "mysql", "sqlite", required)
- `count` (integer, required): min 0; max 1000
- `statements` (array of object, required): max items 1000

## Limits

- max input bytes: 262144
- max statements: 1000
- max delimiter bytes: 16
- max delimiter directives: 32
- max block comment depth: 64

## Example

Request input:

```json
{
  "text": "SELECT ';'; SELECT 2;",
  "dialect": "postgresql"
}
```

Response:

```json
{
  "result": {
    "dialect": "postgresql",
    "count": 2,
    "statements": [
      {
        "start": 0,
        "end": 10,
        "text": "SELECT ';'"
      },
      {
        "start": 12,
        "end": 20,
        "text": "SELECT 2"
      }
    ]
  }
}
```

## How to call it

### MCP

Connect `https://computefirst.net/mcp` ([setup](/docs#connect)), then call `execute` with:

```json
{
  "id": "sql-statements-split",
  "version": "1.0.0",
  "input": {
    "text": "SELECT ';'; SELECT 2;",
    "dialect": "postgresql"
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/sql-statements-split/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"text":"SELECT '\'';'\''; SELECT 2;","dialect":"postgresql"}'
```

The machine-readable contract is at [/v1/tools/sql-statements-split/versions/1.0.0](/v1/tools/sql-statements-split/versions/1.0.0).

### CLI

```sh
node cli.mjs run sql-statements-split 1.0.0 --input input.json --base-url https://computefirst.net
```

Get the client at [/clients/cli/](/clients/cli/).

## Related tools

- [Commit conventional parse](/tools/commit-conventional-parse): Parse one Conventional Commits 1.0.0 message into its header, body, footers, and breaking-change status.
- [Openapi operation extract](/tools/openapi-operation-extract): Extract one OpenAPI operation, merge inherited parameters, and return its local component-reference closure.
- [Tap output parse](/tools/tap-output-parse): Parse TAP version 13 text into ordered assertions, plan validity, diagnostics, directives, and bailout state.
- [Chmod mode convert](/tools/chmod-mode-convert): Convert a Unix permission mode and apply explicit chmod symbolic clauses, returning canonical octal and symbolic forms.
- [Editorconfig resolve](/tools/editorconfig-resolve): Resolve EditorConfig properties for one normalized relative POSIX path from caller-supplied file contents.
- [Shell argv quote](/tools/shell-argv-quote): Quote inert argv strings for POSIX sh or PowerShell 7, returning a command and its per-argument fragments.
