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

Support for Oracle-compatible mode in OBClient

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

Overview
Support for DBMS_OUTPUT
conn command (Oracle compatibility)
Syntax
Examples
Description
define command
Syntax
Description
Examples
Use with SET DEFINE
/(slash) separator
Description
Examples
Differences from other separators
PL/SQL support
Example of creating a stored procedure
Example of creating a function
Oracle syntax compatibility
Data types
System functions and packages
String and date formats
Example
References

OBClient supports connecting to tenants of OceanBase Database in Oracle-compatible mode and provides the following features specific to Oracle-compatible mode.

Overview

When OBClient connects to a tenant in Oracle-compatible mode, it automatically recognizes Oracle syntax features, including:

  • Using / as the statement separator (within PL/SQL blocks)
  • Oracle-style string and date formats
  • Oracle system functions and packages
  • PL/SQL syntax support

Support for DBMS_OUTPUT

OBClient supports Oracle's DBMS_OUTPUT package, which can display output information from stored procedures on the client. Use the SET SERVEROUTPUT command to control whether to pull and display DBMS_OUTPUT output after a query:

SET SERVEROUTPUT ON;
SET SERVEROUTPUT OFF;

conn command (Oracle compatibility)

OBClient is compatible with Oracle SQL*Plus's conn command for switching connections.

Syntax

conn [username[/password][@connect_identifier]];

Examples

Switch connections within the same tenant

Switch to another database within the same tenant:

obclient> conn tom@oboraclegbk#obcluster421/tom;

Switch connections across tenants

Switch to another tenant:

obclient> conn SYS@oboracle#obcluster421/WElcome12#_;

SQL*Plus compatible format

Use the SQL*Plus compatible format:

obclient> conn tom/tom;

Description

The conn command is an alias for the connect command and is fully compatible with the syntax of Oracle SQL*Plus. Using the conn command disconnects the current connection and establishes a new one.

define command

The define command is used to define user variables and is compatible with the variable substitution feature of Oracle SQL*Plus.

Syntax

DEFINE [variable] [= value]

Description

  • Defines (names) a substitution variable and assigns it a CHAR value.
  • Type DEFINE followed by the variable name to list the variable's value and type.
  • Type DEFINE without parameters to list the values and types of all substitution variables.

Examples

obclient> DEFINE name = 'Alice';
obclient> SELECT 'Hello, &name' FROM dual;
Hello, Alice

obclient> DEFINE name
DEFINE NAME = "Alice" (CHAR)

obclient> DEFINE
DEFINE _DATE = "2024-01-01" (CHAR)
DEFINE NAME = "Alice" (CHAR)

Use with SET DEFINE

Using the define command together with the SET DEFINE command allows you to control variable substitution behavior. For more information, see SET variables.

/(slash) separator

OBClient supports using / as a statement separator, especially when executing PL/SQL blocks.

Description

  • Executes the most recently executed SQL command or the PL/SQL block stored in the SQL buffer.
  • The slash command is similar to RUN, but does not list commands.
  • Executing SQL commands or PL/SQL blocks using the slash command does not change the current line number in the SQL buffer, unless the buffer contains an error.

Examples

Use / as a separator in a PL/SQL block:

obclient> BEGIN
    ->   DBMS_OUTPUT.PUT_LINE('Hello, OceanBase!');
    -> END;
    -> /
Hello, OceanBase!

PL/SQL procedure successfully completed.

Differences from other separators

  • ;: SQL statement separator
  • \g: Executes the current SQL statement
  • \G: Displays query results vertically
  • /: Mainly used as a separator for PL/SQL blocks, compatible with Oracle SQL*Plus

PL/SQL support

OBClient supports PL/SQL syntax in Oracle-compatible mode, including:

  • Creating and executing stored procedures, functions, and packages
  • Anonymous PL/SQL blocks
  • Oracle data types and functions

Example of creating a stored procedure

obclient> CREATE OR REPLACE PROCEDURE hello_world AS
    -> BEGIN
    ->   DBMS_OUTPUT.PUT_LINE('Hello, World!');
    -> END;
    -> /

Procedure created.

obclient> EXEC hello_world;
Hello, World!

PL/SQL procedure successfully completed.

Example of creating a function

obclient> CREATE OR REPLACE FUNCTION add_numbers(a NUMBER, b NUMBER)
    -> RETURN NUMBER AS
    -> BEGIN
    ->   RETURN a + b;
    -> END;
    -> /

Function created.

obclient> SELECT add_numbers(10, 20) FROM dual;
ADD_NUMBERS(10,20)
------------------
                30

Oracle syntax compatibility

When OBClient connects to an Oracle-compatible tenant, it automatically recognizes the following Oracle syntax features:

Data types

  • Oracle data types such as NUMBER, VARCHAR2, CHAR, DATE, and TIMESTAMP
  • Large object types such as BLOB, CLOB, and NCLOB

System functions and packages

  • Date and time functions such as SYSDATE and SYSTIMESTAMP
  • System packages such as DBMS_OUTPUT and DBMS_RANDOM
  • Use of the DUAL table

String and date formats

  • Oracle-style string concatenation (||)
  • Oracle date format functions (TO_CHAR, TO_DATE, etc.)

Example

obclient> SELECT SYSDATE FROM dual;
SYSDATE
----------
2024-01-01 12:00:00

obclient> SELECT 'Hello' || ' ' || 'World' AS greeting FROM dual;
GREETING
----------
Hello World

obclient> SELECT TO_CHAR(SYSDATE, 'YYYY-MM-DD HH24:MI:SS') FROM dual;
TO_CHAR(SYSDATE,'YYYY-MM-DDHH24:MI:SS')
----------------------------------------
2024-01-01 12:00:00

References

  • Overview of OBClient
  • Quick start with OBClient
  • Interactive command reference for OBClient
  • SET variables

Previous topic

Reference for OBClient internal commands
Last

Next topic

Log in to OBClient through a socket5 proxy
Next
on this page
Overview
Support for DBMS_OUTPUT
conn command (Oracle compatibility)
Syntax
Examples
Description
define command
Syntax
Description
Examples
Use with SET DEFINE
/(slash) separator
Description
Examples
Differences from other separators
PL/SQL support
Example of creating a stored procedure
Example of creating a function
Oracle syntax compatibility
Data types
System functions and packages
String and date formats
Example
References