Help Center/ Distributed Database Middleware/ User Guide/ SQL Syntax/ Supported SQL Statements/ Obtaining Routes Using HINT to Execute SQL Statements on Segments
Updated on 2026-08-04 GMT+08:00

Obtaining Routes Using HINT to Execute SQL Statements on Segments

Obtain the route based on the SQL statement to calculate the target shard, and then execute the SQL statement on the target shard.

Command format:

/*+sql= <SQL statement for obtaining route information> */ <your query>;

Example:

/*+sql = select * from users where user_id=20*/ select count(*) from orders2_1;

Constraints:

  • The SQL statement for obtaining routes supports only the SELECT statement that can be directly pushed down.
  • The hint is valid only for SELECT, DML, and TRUNCATE statements.
  • The hint works only under the text protocol, rather than the Prepare protocol.