// DuckDB error reference

Parser Error: The SQL does not parse

DuckDB could not parse the statement at all, and the message names the first token that broke the grammar.

Exception
Parser Error
Categoría
Parser and syntax errors
Mensaje de error
Parser Error: syntax error at or near "SELEC"

Qué significa

Parser Error: syntax error at or near "..." is DuckDB's pure syntax failure: the text is not valid SQL grammar, so nothing was planned or executed. The quoted token is where the parser gave up, which is usually at or just after the real mistake. Client libraries raise the same class on their side, typically as a ParserException.

The token itself is often innocent; the error is what comes before it, such as a doubled comma, an unclosed parenthesis, a reserved word used as an identifier, or a keyword misspelled. An unclosed quote gives a different message, Parser Error: unterminated string literal. Statements pasted from other dialects fail here too, for example SQL Server's square-bracket identifiers, which DuckDB does not read. Backtick quoting stopped failing in DuckDB 2.0, which now reads MySQL-style backtick identifiers.

Causas comunes

  • A misspelled keyword such as SELEC, or a keyword used as a column name without quoting.
  • A missing or extra comma, parenthesis, or closing quote earlier in the statement.
  • Syntax from another dialect: square-bracket identifiers that are keywords, such as [order], or TOP instead of LIMIT (backtick quoting parses since DuckDB 2.0).
  • Splitting a script on semicolons and sending a fragment, so a statement starts mid-expression.

Find the cause

-- Binary search the statement: run it with parts removed until the error moves.
-- Check how the text reached DuckDB, character by character, when the SQL looks right:
SELECT length('  SELEC 1  ');
-- In application logs, print the statement exactly as bound, with parameters filled in.

Cómo solucionarlo

  1. Look at the token before the one named in the message; that is usually where the mistake is.

  2. Quote identifiers with double quotes when they collide with keywords:

    SELECT "order", "group" FROM t;
  3. Translate dialect syntax to DuckDB: LIMIT instead of TOP, standard double-quote identifiers:

    SELECT [order] FROM t;
    -- becomes
    SELECT "order" FROM t LIMIT 10;
  4. Build statements in code with parameters instead of string splicing, which is where most stray quotes come from:

    SELECT * FROM t WHERE id = ?;

Other ways to handle it

If generated SQL keeps failing, switch from string concatenation to the driver's parameter binding; it removes quoting bugs and injection risk at once. For a whole script, run it through the DuckDB CLI or a .sql file rather than splitting on semicolons in code, since that breaks on semicolons inside string literals.

Reprodúcelo de forma segura

SELEC 1;   -- Parser Error: syntax error at or near "SELEC"

Preguntas

Parser Error or Binder Error: what is the difference?

A Parser Error means the text is not valid SQL grammar. A Binder Error means the SQL parsed but names or types could not be resolved against the schema.

The token in the message looks fine. What now?

Check before it: an unclosed parenthesis makes the parser fail at the first token after the gap, so the reported position is downstream of the real mistake. An unclosed quote is different: DuckDB reports Parser Error: unterminated string literal with the caret on the opening quote.

Errores relacionados

El código y el texto del mensaje son de DuckDB documentation. Explora la lista completa de DuckDB error list o buscar cada error de base de datos.

// menos errores, correcciones más rápidas

Work on DuckDB in SQLly

A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for DuckDB and the other databases you use.

Texto y datos de esta página: CC BY 4.0, con atribución a SQLly (sqlly.app). Código y fragmentos SQL: MIT. Detalles de la licencia El texto citado de los mensajes de error pertenece a su proveedor de base de datos.