EXECUTE

EXECUTE 语句为服务器端预处理语句提供 SQL 接口。

语法图

ExecuteStmt

EXECUTE - 图1

  1. ExecuteStmt ::=
  2. 'EXECUTE' Identifier ( 'USING' UserVariable ( ',' UserVariable )* )?

示例

  1. PREPARE mystmt FROM 'SELECT ? as num FROM DUAL';
  1. Query OK, 0 rows affected (0.00 sec)
  1. SET @number = 5;
  1. Query OK, 0 rows affected (0.00 sec)
  1. EXECUTE mystmt USING @number;
  1. +------+
  2. | num |
  3. +------+
  4. | 5 |
  5. +------+
  6. 1 row in set (0.00 sec)
  1. DEALLOCATE PREPARE mystmt;
  1. Query OK, 0 rows affected (0.00 sec)

MySQL 兼容性

EXECUTE 语句与 MySQL 完全兼容。如发现任何兼容性差异,请尝试 TiDB 支持资源

另请参阅