DROP_FUNCTION(7)
๐ DROP_FUNCTION ๐
okay bestie, gather round, because today we're learning how to yeet a function out of existence ๐ซถ
DROP_FUNCTION โ remove a function โจ
โจ SYNOPSIS โจ
DROP FUNCTION [ IF EXISTS ] name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ] [, ...]
[ CASCADE | RESTRICT ]
๐ธ DESCRIPTION ๐ธ
So like. DROP FUNCTION removes the definition of an existing function. That's it, that's the whole vibe. ๐
But no cap, there are rules:
- to run this command, you must be the owner of the function. not your cousin, not your group chat, you. ๐
- you gotta specify the argument types of the function, because lowkey several different functions can have the exact same name with different argument lists. it's giving "same name, different energy" โ so the arg types are how Postgres tells them apart. ๐ฅ
๐ PARAMETERS ๐
IF EXISTSโ don't throw an error if the function doesn't exist. instead a notice gets issued. so like, no dramatic meltdown, just a little "hmm, wasn't there anyway" note. ๐nameโ the name (optionally schema-qualified) of an existing function. if you don't give an argument list, then the name has to be unique in its schema. periodt.argmodeโ the mode of an argument:IN,OUT,INOUT, orVARIADIC. if you omit it, the default isIN. now here's the tea ๐ต:DROP FUNCTIONdoes not actually pay any attention toOUTarguments, since only the input arguments are needed to determine the function's identity. so it's sufficient to list theIN,INOUT, andVARIADICarguments. theOUTones are just... there. main character energy but no lines. ๐ญ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. names are decoration, bestie. cute but irrelevant. โจargtypeโ the data type(s) of the function's arguments (optionally schema-qualified), if any. the actual identity check. the real one. ๐CASCADEโ 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, it's giving chain reaction. ๐ฆRESTRICTโ refuse to drop the function if any objects depend on it. this is the default. she's cautious, she's responsible, she said no. ๐
๐ EXAMPLES ๐
this command removes the square root function:
DROP FUNCTION sqrt(integer);
drop multiple functions in one command โ multitasking queen ๐ :
DROP FUNCTION sqrt(integer), sqrt(bigint);
if the function name is unique in its schema, it can be referred to without an argument list:
DROP FUNCTION update_employee_salaries;
note that this is different from
DROP FUNCTION update_employee_salaries();
which 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 bestie, those two lines are lowkey not the same thing. the parentheses are doing so much work. ๐
โญ COMPATIBILITY โญ
this command conforms to the SQL standard, with these PostgreSQL extensions:
- the standard only allows one function to be dropped per command.
- the
IF EXISTSoption - the ability to specify argument modes and names
so like, we're standard-compliant and we brought extras. overachiever behaviour. ๐
๐ฆ SEE ALSO ๐ฆ
CREATE FUNCTION(CREATE_FUNCTION(7))ALTER FUNCTION(ALTER_FUNCTION(7))DROP PROCEDURE(DROP_PROCEDURE(7))DROP ROUTINE(DROP_ROUTINE(7))
and that's the whole page, bestie ๐ this one's from PostgreSQL 18.6, dated 2026, and it's literally called DROP FUNCTION(7). go forth and drop responsibly, mwah ๐ซถโจ
๐ฆ where this page comes from
- alpine 3.23: postgresql18-doc 18.6-r0 ยท PostgreSQL
- alpine 3.24: postgresql18-doc 18.6-r0 ยท PostgreSQL
- arch rolling: postgresql 18.6-4 ยท PostgreSQL
- fedora 43: postgresql 18.6-1.fc43 ยท PostgreSQL
- fedora 43: postgresql 18.6-1.fc43 ยท PostgreSQL
- fedora 44: postgresql 18.6-1.fc44 ยท PostgreSQL
- fedora 44: postgresql 18.6-1.fc44 ยท PostgreSQL
- nixos 26.05: postgresql 18.6
- ubuntu resolute: postgresql-client-18 18.6-0ubuntu0.26.04.1 ยท PostgreSQL
- ubuntu stonking: postgresql-client-18 18.6-3build2 ยท PostgreSQL
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms