DROP_FUNCTION(7pg13)
π DROP FUNCTION (7pg13) β the glow-up edition π¦
Okay bestie, so likeβ¦ we're talking PostgreSQL 13.23 here, and this page is literally all about yeeting a function out of existence. No cap, it's the DROP FUNCTION page, and it's giving "cleanup era" energy. Let's get into it π
β¨ NAME β¨
DROP_FUNCTION β remove a function. That's it. That's the vibe. Bye-bye function, you had a good run π
πΈ SYNOPSIS πΈ
DROP FUNCTION [ IF EXISTS ] name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ] [, ...]
[ CASCADE | RESTRICT ]
Look at that syntax, it's literally gorgeous. Copy it exactly, bestie, don't freestyle it π
π¦ DESCRIPTION π¦
So DROP FUNCTION removes the definition of an existing function. Iconic behavior, honestly. But here's the tea: to run this command, you gotta be the owner of the function. Like, it's your function, you can drop it if you want to π«Ά
Also, you must specify the argument types to the function. Why? Because several different functions can totes exist with the same name but different argument lists. So the types are how Postgres knows which one you mean. It's giving "be specific or be sorry" β¨
π PARAMETERS π (the deets, iykyk)
IF EXISTSβ Do not throw an error if the function doesn't exist. Instead, a notice gets issued. So it's like "no function? no problem, just a lil note" ππ¦nameβ The name (optionally schema-qualified) of an existing function. If you don't specify an argument list, the name must be unique in its schema. No duplicates allowed, periodt πargmodeβ The mode of an argument:IN,OUT,INOUT, orVARIADIC. If you omit it, the default isIN. Lowkey important: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. Like,OUTis just there for vibes πargnameβ The name of an argument. Fun fact:DROP FUNCTIONdoes not pay any attention to argument names either, since only the argument data types are needed to determine the function's identity. So you can skip the names, bestie, the types are what matter fr fr πargtypeβ The data type(s) of the function's arguments (optionally schema-qualified), if any. This is the main character of the parameter list, not gonna lie πCASCADEβ Automatically drop objects that depend on the function (like operators or triggers), and in turn all objects that depend on those objects (see Section 5.14). It's like a chain reaction, a whole domino effect, and honestly? Kinda dramatic ππ₯RESTRICTβ Refuse to drop the function if any objects depend on it. This is the default. So if you don't say anything, Postgres is like "hmm, something depends on this? nope, not doing it" π ββοΈ
π§ EXAMPLES π§ (show me the moves)
This command removes the square root function:
DROP FUNCTION sqrt(integer);
Drop multiple functions in one command β yes bestie, you can do that, it's giving efficiency:
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();
The one with the empty parentheses refers to a function with zero arguments, whereas the first variant (no parentheses at all) can refer to a function with any number of arguments, including zero, as long as the name is unique. The way that's such a subtle but iconic distinction πβ¨
π COMPATIBILITY π
This command conforms to the SQL standard, with these PostgreSQL extensions:
- The standard only allows one function to be dropped per command. PostgreSQL said "we can do better" π
- The
IF EXISTSoption - The ability to specify argument modes and names
So yeah, Postgres is out here being extra in the best way possible π
β SEE ALSO β
CREATE FUNCTION (CREATE_FUNCTION(7))β for making functionsALTER FUNCTION (ALTER_FUNCTION(7))β for changing functionsDROP PROCEDURE (DROP_PROCEDURE(7))β for the procedure girliesDROP ROUTINE (DROP_ROUTINE(7))β the routine option
π One last thing, bestie: dropping functions is permanent, so double-check before you yeet. No undo button, no cap. Be careful out there π«Ά
And that's the whole page, fr fr. This was PostgreSQL 13.23, dated 2025, and honestly? She ate. Periodt. πΈπ β¨
π¦ where this page comes from
- opensuse-leap 16.0: postgresql13 13.23-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql13 13.23-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql13 13.23-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql13 13.23-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