drop Verified current stable Not installed? Programming

Drop / Delete Function

Delete Function

Removes a specified function from the database.

$
Terminal
drop function <func_name>;

When To Use

When refactoring a database to remove unused or obsolete functions.

Pro Tip

Use CASCADE if dependent objects exist to avoid orphaned references, but verify dependencies first.

Command Builder

Tune the command before you copy it

Back to syntax
$
Generated Command
drop function <func_name>;

Anatomy of Output

Understanding the result

DROP FUNCTION func_name; Command

Executes the function removal.

Function "func_name" does not exist. Confirmation

Indicates that the function was not found.

Query OK, 0 rows affected. Output

Confirms the function was successfully removed.

Power User Variants

Optimized versions

DROP FUNCTION IF EXISTS func_name;

Safely drops a function if it exists, preventing errors.

DROP FUNCTION func_name CASCADE;

Drops the function and any dependent objects.

Troubleshooting

Common pitfalls

ERROR: function func_name does not exist

Solution: Check the function name for typos or verify its existence.

ERROR: function func_name is still being referenced

Solution: Use CASCADE to drop dependent objects or remove the references first.

ERROR: insufficient privileges to drop function "func_name"

Solution: Ensure you have the correct permissions.

Command Breakdown

What each part is doing

drop
Base Command
The executable that performs this operation. Here it runs Drop before the shell applies any redirect operators.
<func_name>
func name
The value supplied for func name.

Alternative Approaches

Comparable commands in other tools

Alternative programming tools for the same job.