DROP_FUNCTION(7pg13)

πŸ“¦ version 13.23, in opensuse-leap 16.0

πŸ’… 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, or VARIADIC. If you omit it, the default is IN. Lowkey important: DROP FUNCTION does not actually pay any attention to OUT arguments, since only the input arguments are needed to determine the function's identity. So it's sufficient to list the IN, INOUT, and VARIADIC arguments. Like, OUT is just there for vibes 🌈
  • argname β€” The name of an argument. Fun fact: DROP FUNCTION does 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 EXISTS option
  • The ability to specify argument modes and names

So yeah, Postgres is out here being extra in the best way possible 🌈


⭐ SEE ALSO ⭐


πŸ’– 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