DROP_PROCEDURE(7pg13)

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

πŸ’… DROP PROCEDURE β€” bestie, we're deleting a procedure

okay so real talk β€” this is the DROP PROCEDURE page from the PostgreSQL 13.23 Documentation, and we're about to learn how to yeet a stored procedure into the void. no cap, it's easier than it sounds πŸ¦‹


✨ SYNOPSIS ✨

DROP PROCEDURE [ IF EXISTS ] name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ] [, ...]
    [ CASCADE | RESTRICT ]

look at her. iconic. one command, so many brackets πŸ’€


🌸 DESCRIPTION 🌸

DROP PROCEDURE removes the definition of an existing procedure. that's the whole vibe β€” girl is gone.

But (and this is the part where you gotta pay attention, bestie 🫢) to run this command the user must be the owner of the procedure. not your friend, not your coworker β€” you. owner energy only πŸ‘‘

also you must specify the argument types to the procedure, because β€” plot twist β€” several different procedures can totally exist with the same name and different argument lists. so the arg types are how Postgres tells them apart. it's giving "which twin are you" energy 😭


πŸŽ€ PARAMETERS πŸŽ€

  • IF EXISTS β€” don't throw an error if the procedure doesn't exist. instead, a notice is issued in this case. so like, if it's not there, Postgres just goes "ok noted" instead of yelling at you πŸ’…
  • name β€” the name (optionally schema-qualified) of an existing procedure. if no argument list is specified, the name must be unique in its schema. lowkey important detail, don't skip it ✨
  • argmode β€” the mode of an argument: IN or VARIADIC. if omitted, the default is IN. that's it, that's the whole menu πŸ“
  • argname β€” the name of an argument. but note that DROP PROCEDURE does not actually pay any attention to argument names, since only the argument data types are needed to determine the procedure's identity. so like… you can write it, she just won't read it πŸ™ˆ
  • argtype β€” the data type(s) of the procedure's arguments (optionally schema-qualified), if any. this is the one that actually matters, the main character of the parameter list ⭐
  • CASCADE β€” automatically drop objects that depend on the procedure, and in turn all objects that depend on those objects (see Section 5.14). it's giving domino effect, it's giving chain reaction πŸ”₯
  • RESTRICT β€” refuse to drop the procedure if any objects depend on it. this is the default. yes, the safe one is the default, we love a cautious queen 🌈
ok warning time πŸ’€ β€” CASCADE is not playing around. it will take out everything that depends on your procedure, and everything that depends on that. make sure you mean it before you type it, fr fr.

🧚 EXAMPLES 🧚

DROP PROCEDURE do_db_maintenance();

that's it. that's the example. she's simple, she's clean, she ate πŸ’–


πŸ”₯ COMPATIBILITY πŸ”₯

this command conforms to the SQL standard β€” slay β€” with these PostgreSQL extensions:

  • The standard only allows one procedure to be dropped per command. (we do more. we're built different πŸ‘‘)
  • The IF EXISTS option
  • The ability to specify argument modes and names

πŸ¦‹ SEE ALSO πŸ¦‹


and that's the whole page, bestie 🫢 go forth and drop responsibly. this was written up for PostgreSQL 13.23, dated 2025, and yes β€” that's the same DROP PROCEDURE(7) girl you came in with. periodt πŸ’…βœ¨

πŸ“¦ where this page comes from