EXECUTE

The EXECUTE statement provides an SQL interface to server-side prepared statements.

Synopsis

ExecuteStmt

EXECUTE - 图1

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

Examples

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

MySQL compatibility

The EXECUTE statement in TiDB is fully compatible with MySQL. If you find any compatibility differences, report a bug.

See also