# DEALLOCATE / DROP PREPARE

## Syntax

```sql
{DEALLOCATE | DROP} PREPARE stmt_name
```

## Description

To deallocate a prepared statement produced with [PREPARE](https://mariadb.com/docs/server/reference/sql-statements/prepared-statements/prepare-statement), use a`DEALLOCATE PREPARE` statement that refers to the prepared statement name.

A prepared statement is implicitly deallocated when a new `PREPARE` command is issued. In that case, there is no need to use `DEALLOCATE`.

Attempting to execute a prepared statement after deallocating it results in an error, as if it was not prepared at all:

```sql
ERROR 1243 (HY000): Unknown prepared statement handler (stmt_name) given to EXECUTE
```

If the specified statement has not been PREPAREd, an error similar to the following will be produced:

```sql
ERROR 1243 (HY000): Unknown prepared statement handler (stmt_name) given to DEALLOCATE PREPARE
```

## Example

See [example in PREPARE](https://mariadb.com/docs/server/reference/sql-statements/prepare-statement#example).

## See Also

* [PREPARE Statement](https://mariadb.com/docs/server/reference/sql-statements/prepared-statements/prepare-statement)
* [EXECUTE Statement](https://mariadb.com/docs/server/reference/sql-statements/prepared-statements/execute-statement)
* [EXECUTE IMMEDIATE](https://mariadb.com/docs/server/reference/sql-statements/prepared-statements/execute-immediate)

<sub>*This page is licensed: GPLv2, originally from*</sub> [<sub>*fill\_help\_tables.sql*</sub>](https://github.com/MariaDB/server/blob/main/scripts/fill_help_tables.sql)

{% @marketo/form formId="4316" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mariadb.com/docs/server/reference/sql-statements/prepared-statements/deallocate-drop-prepare.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
