DEALLOCATE PREPARE

Description

To deallocate a prepared statement produced with PREPARE, use a DEALLOCATE PREPARE statement that refers to the prepared statement name. Attempting to execute a prepared statement after deallocating it results in an error. If too many prepared statements are created and not deallocated by either the DEALLOCATE PREPARE statement or the end of the session, you might encounter the upper limit enforced by the max_prepared_stmt_count system variable.

Syntax

  1. {DEALLOCATE | DROP} PREPARE stmt_name

Arguments

ArgumentsDescription
stmt_nameThe name of the prepared statement.

Examples

  1. > CREATE TABLE numbers(pk INTEGER PRIMARY KEY, ui BIGINT UNSIGNED, si BIGINT);
  2. > INSERT INTO numbers VALUES (0, 0, -9223372036854775808), (1, 18446744073709551615, 9223372036854775807);
  3. > SET @si_min = -9223372036854775808;
  4. > SET @si_max = 9223372036854775807;
  5. > PREPARE s2 FROM 'SELECT * FROM numbers WHERE si=?';
  6. Query OK, 0 rows affected (0.00 sec)
  7. > EXECUTE s2 USING @si_min;
  8. +------+------+----------------------+
  9. | pk | ui | si |
  10. +------+------+----------------------+
  11. | 0 | 0 | -9223372036854775808 |
  12. +------+------+----------------------+
  13. 1 row in set (0.01 sec)
  14. > EXECUTE s2 USING @si_max;
  15. +------+----------------------+---------------------+
  16. | pk | ui | si |
  17. +------+----------------------+---------------------+
  18. | 1 | 18446744073709551615 | 9223372036854775807 |
  19. +------+----------------------+---------------------+
  20. 1 row in set (0.01 sec)
  21. > DEALLOCATE PREPARE s2;
  22. Query OK, 0 rows affected (0.00 sec)