> For the complete documentation index, see [llms.txt](https://mariadb.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mariadb.com/docs/server/server-usage/stored-routines/stored-functions/drop-function.md).

# DROP FUNCTION

## Syntax

```bnf
DROP FUNCTION [IF EXISTS] f_name
```

## Description

The `DROP FUNCTION` statement is used to drop a [stored function](/docs/server/server-usage/stored-routines/stored-functions.md) or a user-defined function (UDF). That is, the specified routine is removed from the server, along with all privileges specific to the function. You must have the `ALTER ROUTINE` [privilege](/docs/server/reference/sql-statements/account-management-sql-statements/grant.md) for the routine in order to drop it. If the [automatic\_sp\_privileges](/docs/server/server-management/variables-and-modes/server-system-variables.md#automatic_sp_privileges) server system variable is set, both the `ALTER ROUTINE` and `EXECUTE` privileges are granted automatically to the routine creator - see [Stored Routine Privileges](/docs/server/server-usage/stored-routines/stored-functions/stored-routine-privileges.md).

#### IF EXISTS

The `IF EXISTS` clause is a MySQL/MariaDB extension. It prevents an error from occurring if the function does not exist. A`NOTE` is produced that can be viewed with [SHOW WARNINGS](/docs/server/reference/sql-statements/administrative-sql-statements/show/show-warnings.md).

For dropping a [user-defined functions](/docs/server/server-usage/user-defined-functions.md) (UDF), see [DROP FUNCTION UDF](/docs/server/server-usage/user-defined-functions/drop-function-udf.md).

## Examples

```sql
DROP FUNCTION hello;
Query OK, 0 rows affected (0.042 sec)

DROP FUNCTION hello;
ERROR 1305 (42000): FUNCTION test.hello does not exist

DROP FUNCTION IF EXISTS hello;
Query OK, 0 rows affected, 1 warning (0.000 sec)

SHOW WARNINGS;
+-------+------+------------------------------------+
| Level | Code | Message                            |
+-------+------+------------------------------------+
| Note  | 1305 | FUNCTION test.hello does not exist |
+-------+------+------------------------------------+
```

## See Also

* [DROP PROCEDURE](/docs/server/server-usage/stored-routines/stored-procedures/drop-procedure.md)
* [Stored Function Overview](/docs/server/server-usage/stored-routines/stored-functions/stored-function-overview.md)
* [CREATE FUNCTION](/docs/server/reference/sql-statements/data-definition/create/create-function.md)
* [CREATE FUNCTION UDF](/docs/server/server-usage/user-defined-functions/create-function-udf.md)
* [ALTER FUNCTION](/docs/server/reference/sql-statements/data-definition/alter/alter-function.md)
* [SHOW CREATE FUNCTION](/docs/server/reference/sql-statements/administrative-sql-statements/show/show-create-function.md)
* [SHOW FUNCTION STATUS](/docs/server/reference/sql-statements/administrative-sql-statements/show/show-function-status.md)
* [Stored Routine Privileges](/docs/server/server-usage/stored-routines/stored-functions/stored-routine-privileges.md)
* [INFORMATION\_SCHEMA ROUTINES Table](/docs/server/reference/system-tables/information-schema/information-schema-tables/information-schema-routines-table.md)

<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" %}
