OceanBase
English日本語简体中文
Docs Home
Products
Integrations
Release Notes

Databases

OceanBase DatabaseOceanBase Cloud OceanBase Best Practices

Tools

OceanBase Cloud PlatformOceanBase Migration ServiceOceanBase Developer CenterOceanBase Migration AssessmentOceanBase Admin ToolOceanBase Loader and DumperOceanBase DeployerKubernetes operator for OceanBaseOceanBase Diagnostic Tool OceanBase Binlog Service

Connectors and Middleware

OceanBase Database Proxy OceanBase Connector/C OceanBase Connector/J OceanBase Connector/ODBC OceanBase Connector/NETOceanBase Command-Line Client

Databases

OceanBase DatabaseOceanBase Cloud OceanBase Best Practices

Connectors and Middleware

OceanBase Database Proxy OceanBase Connector/C OceanBase Connector/J OceanBase Connector/ODBC OceanBase Connector/NETOceanBase Command-Line Client

Tools

OceanBase Cloud PlatformOceanBase Migration ServiceOceanBase Developer CenterOceanBase Migration AssessmentOceanBase Admin ToolOceanBase Loader and DumperOceanBase DeployerKubernetes operator for OceanBaseOceanBase Diagnostic Tool OceanBase Binlog Service
OceanBase DatabaseOceanBase Cloud ToolsConnectors and MiddlewareLifecycle Support Policy

OceanBase Command-Line Client

V2.2.13
  • Introduction
    • Overview of OBClient
  • Quick start
    • Quick start with OBClient
  • Command-line options
    • Common OBClient command-line options
    • Reference for OBClient command-line options
    • SQL context when a script fails
  • Configuration and environment
    • Configure OBClient and set environment variables
  • User guide
    • Reference for OBClient internal commands
  • Advanced features
    • Support for Oracle-compatible mode in OBClient
    • Log in to OBClient through a socket5 proxy
    • Multi-IP connection support for OBClient
    • Client IP passthrough and tenant allowlist (F5 scenario)
    • Log in as a proxy user of OBClient
    • LOAD DATA LOCAL INFILE
    • SET variables
    • Supported login_path options for OBClient
  • Tips and troubleshooting
    • OBClient Usage Tips and Troubleshooting

Download PDF

Document Feedback
  1. Documentation Center
  2. OceanBase Command-Line Client
  3. V2.2.13

SQL context when a script fails

Last Updated:2026-09-02 09:17:42

Parameter description
Usage example
References

When executing scripts batches of statements via OBClient (for example, using the -e option, input redirection, or executing multiple statements with source), it can sometimes be difficult to immediately identify which specific SQL statements caused the failure based solely on the error messages returned by the database. The --error-sql option appends the SQL text surrounding the fault point to the error output, making it easier to troubleshoot by comparing it with the script.

This parameter is supported for both MySQL-compatible mode and Oracle-compatible mode tenants in OceanBase Database.

Parameter description

Syntax
Description
--error-sql=xxx Enable context output. It is conventionally represented asxxxAs a placeholder literal, it indicates "Enable this capability". After enabling, the first 5 lines of the relevant SQL will be displayed by default near the error message (consistent with common release notes; if different from your on-site version, the actual client shall prevail).
--error-sql=top0 When enabled, it tries to output the most complete relevant SQL statements possible before the error occurs.
--error-sql=topN When enabled, the system outputs the N most recent SQL statements before the error occurred. (NA positive integer, for example,top3(That is, the first three rows).

Usage example

Replace the address, port, username, and database name in the connection string with your environment's values:

obclient -h127.0.0.1 -P2881 -uroot@mysql -Dtest --error-sql=xxx
obclient -h127.0.0.1 -P2881 -uroot@mysql -Dtest --error-sql=top0
obclient -h127.0.0.1 -P2881 -uroot@mysql -Dtest --error-sql=top3

Note

Whether "lines" in the output correspond to physical lines of the script or are split by statements depends on the client implementation and version. After upgrading OBClient, we recommend testing your script in a pre-release environment with the same script as used online to confirm whether the rollback granularity still meets your troubleshooting habits.

References

  • Command-line options reference
  • Quick overview of common command-line options
  • Tips and troubleshooting

Previous topic

Reference for OBClient command-line options
Last

Next topic

Configure OBClient and set environment variables
Next
on this page
Parameter description
Usage example
References