DROP_FUNCTION(7pg17)
π
DROP FUNCTION β the "bestie, delete this function" page (PostgreSQL 17.11 docs, DROP_FUNCTION(7))
okay so real talk, this one's a banger. let's get into it β¨
πΈ NAME
DROP_FUNCTION β remove a function. that's it. that's the whole vibe. yeet the function π«Ά
π SYNOPSIS
DROP FUNCTION [ IF EXISTS ] name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ] [, ...]
[ CASCADE | RESTRICT ]
look at her. iconic. slightly terrifying. very demure syntax π¦
π DESCRIPTION
DROP FUNCTION removes the definition of an existing function. poof. gone. no cap.
but here's the thing bestie: to actually execute this command, the user must be the owner of the function. not your friend, not your coworker, you. π
and the argument types to the function must be specified, because β and this is the plot twist β several different functions can totally exist with the same name and different argument lists. so like, the name alone isn't enough to tell them apart. it's giving "everyone named Emma in this class" energy. π
β¨ PARAMETERS β¨
IF EXISTSβ do not throw an error if the function doesn't exist. a notice is issued in this case instead. so it's the polite version of "hey, she's not here" πnameβ the name (optionally schema-qualified) of an existing function. if no argument list is specified, the name must be unique in its schema. no duplicates allowed, periodt.argmodeβ the mode of an argument:IN,OUT,INOUT, orVARIADIC. if omitted, the default isIN. quick note tho:DROP FUNCTIONdoes not actually pay any attention toOUTarguments, since only the input arguments are needed to determine the function's identity. so it is sufficient to list theIN,INOUT, andVARIADICarguments. slay, less typing πargnameβ the name of an argument. and again:DROP FUNCTIONdoes not actually pay any attention to argument names, since only the argument data types are needed to determine the function's identity. so don't stress about the names, they're just there being decorative πargtypeβ the data type(s) of the function's arguments (optionally schema-qualified), if any. that's the part that actually matters fr frCASCADEβ automatically drop objects that depend on the function (such as operators or triggers), and in turn all objects that depend on those objects (see Section 5.15). it's giving domino effect. be careful with this one π₯RESTRICTβ refuse to drop the function if any objects depend on it. this is the default. the safe, sensible, responsible queen π
β οΈ okay but seriously, CASCADE takes out everything that depends on the function, and then everything that depends on those things. read the dependencies before you go feral π
π EXAMPLES
this command removes the square root function:
DROP FUNCTION sqrt(integer);
drop multiple functions in one command β yes you can do that, we love efficiency:
DROP FUNCTION sqrt(integer), sqrt(bigint);
now this one's cute π if the function name is unique in its schema, it can be referred to without an argument list:
DROP FUNCTION update_employee_salaries;
and note that this is different from
DROP FUNCTION update_employee_salaries();
the second one refers to a function with zero arguments, whereas the first variant can refer to a function with any number of arguments, including zero, as long as the name is unique. yes. that's a whole different thing. no, it doesn't feel fair. it's just how it is π
π COMPATIBILITY
this command conforms to the SQL standard, with these PostgreSQL extensions:
- The standard only allows one function to be dropped per command. we allow more. we're generous like that π
- The
IF EXISTSoption - The ability to specify argument modes and names
π§ SEE ALSO
CREATE FUNCTION(CREATE_FUNCTION(7))ALTER FUNCTION(ALTER_FUNCTION(7))DROP PROCEDURE(DROP_PROCEDURE(7))DROP ROUTINE(DROP_ROUTINE(7))
the whole friend group honestly π«Ά
and that's the page bestie β¨ brought to you by the PostgreSQL 17.11 documentation, dated 2026. go forth and drop responsibly, mwah ππ
π¦ where this page comes from
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms