Name

DROP FUNCTION

Synopsis

This command removes a user-defined function from the current database.

Vendor

Command

SQL Server

Supported, with variations

MySQL

Supported, with variations

Oracle

Supported, with variations

PostgreSQL

Supported, with variations

SQL99 Syntax and Description

DROP FUNCTION function_name {RESTRICT | CASCADE}

This command permanently destroys a function. The RESTRICT clause ensures that the command fails if other database objects, such as a view, depend upon the function. On the other hand, the CASCADE option drops the function, any grants based on the function, and any dependent database objects!

Microsoft SQL Server Syntax and Variations

DROP FUNCTION [owner_name.]function_name [,...n]

As with other SQL Server DROP commands, more than one database object of the same type may be dropped by placing a comma between the names of each database object.

MySQL Syntax and Variations

This command does not actually delete the file containing the function. Instead, it deletes the function reference from the system table, which can be added back by using the CREATE FUNCTION statement.

Oracle Syntax and Variations

DROP FUNCTION [owner_name.]function_name

As with other Oracle DROP commands, the name of the function owner may be specified. Otherwise, Oracle assumes the current-user context, and only functions owned by the current user to be dropped. Alternately, those users with DROP ANY FUNCTION system privilege are allowed to drop any function anywhere.

PostgreSQL Syntax ...

Get SQL in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.