{"Entry":{"collection":"sql","key":"drop-routine","name":"DROP ROUTINE","aliases":["droproutine"],"metadata":{"aliases":["droproutine"],"changed_in":[],"changes":[{"from":"10","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":[],"removed":[]},"status":"added","synopsis":null,"to":"11"},{"from":"13","purpose_changed":false,"renamed":null,"sections":{"added":["notes"],"changed":["description","compatibility"],"removed":[]},"status":"changed","synopsis":null,"to":"14"}],"content_hash":"9a82ec75c3e4dfa6e8606b0c3d688c6ca40ad97d4802c903714ceeb9db1a438a","editorial":{},"first_version":"11","group":"routine","imported_at":"2026-09-30T17:43:37.318204+08:00","last_version":"20","name":"DROP ROUTINE","object":"ROUTINE","position":2015,"present_in":["11","12","13","14","15","16","17","18","19","20"],"purpose":"remove a routine","purpose_zh":"","related":["drop-aggregate","drop-function","drop-procedure","alter-routine"],"slug":"drop-routine","source_rev":"a709ab85","synopsis":"DROP ROUTINE [ IF EXISTS ] name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ] [, ...]\n[ CASCADE | RESTRICT ]","verb":"DROP"}},"Definition":{"Collection":"sql","Key":"drop-routine","SourceDatabase":"center","Version":"18","SourceTable":"sqlcmd","SourceKey":"drop-routine","SourceRevision":"a709ab85","Facts":{"anchor":"SQL-DROPROUTINE","file":"sql-droproutine.html","lang":"en","name":"DROP ROUTINE","purpose":"remove a routine","purpose_zh":"","related":["drop-aggregate","drop-function","drop-procedure","alter-routine"],"sections":[{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eDROP ROUTINE\u003c/code\u003e removes the definition of one or more existing routines. The term \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003eroutine\u003c/span\u003e”\u003c/span\u003e includes aggregate functions, normal functions, and procedures. See under \u003ca href=\"/docs/18/sql-dropaggregate.html\" title=\"DROP AGGREGATE\"\u003e\u003cspan class=\"refentrytitle\"\u003eDROP AGGREGATE\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/docs/18/sql-dropfunction.html\" title=\"DROP FUNCTION\"\u003e\u003cspan class=\"refentrytitle\"\u003eDROP FUNCTION\u003c/span\u003e\u003c/a\u003e, and \u003ca href=\"/docs/18/sql-dropprocedure.html\" title=\"DROP PROCEDURE\"\u003e\u003cspan class=\"refentrytitle\"\u003eDROP PROCEDURE\u003c/span\u003e\u003c/a\u003e for the description of the parameters, more examples, and further details.\u003c/p\u003e","key":"description","title":"Description"},{"html":"\u003cp\u003eThe lookup rules used by \u003ccode class=\"command\"\u003eDROP ROUTINE\u003c/code\u003e are fundamentally the same as for \u003ccode class=\"command\"\u003eDROP PROCEDURE\u003c/code\u003e; in particular, \u003ccode class=\"command\"\u003eDROP ROUTINE\u003c/code\u003e shares that command's behavior of considering an argument list that has no \u003cem class=\"replaceable\"\u003e\u003ccode\u003eargmode\u003c/code\u003e\u003c/em\u003e markers to be possibly using the SQL standard's definition that \u003ccode class=\"literal\"\u003eOUT\u003c/code\u003e arguments are included in the list. (\u003ccode class=\"command\"\u003eDROP AGGREGATE\u003c/code\u003e and \u003ccode class=\"command\"\u003eDROP FUNCTION\u003c/code\u003e do not do that.)\u003c/p\u003e\u003cp\u003eIn some cases where the same name is shared by routines of different kinds, it is possible for \u003ccode class=\"command\"\u003eDROP ROUTINE\u003c/code\u003e to fail with an ambiguity error when a more specific command (\u003ccode class=\"command\"\u003eDROP FUNCTION\u003c/code\u003e, etc.) would work. Specifying the argument type list more carefully will also resolve such problems.\u003c/p\u003e\u003cp\u003eThese lookup rules are also used by other commands that act on existing routines, such as \u003ccode class=\"command\"\u003eALTER ROUTINE\u003c/code\u003e and \u003ccode class=\"command\"\u003eCOMMENT ON ROUTINE\u003c/code\u003e.\u003c/p\u003e","key":"notes","title":"Notes"},{"html":"\u003cp\u003eTo drop the routine \u003ccode class=\"literal\"\u003efoo\u003c/code\u003e for type \u003ccode class=\"type\"\u003einteger\u003c/code\u003e:\u003c/p\u003e\u003cpre class=\"programlisting\"\u003eDROP ROUTINE foo(integer);\n\u003c/pre\u003e\u003cp\u003eThis command will work independent of whether \u003ccode class=\"literal\"\u003efoo\u003c/code\u003e is an aggregate, function, or procedure.\u003c/p\u003e","key":"examples","title":"Examples"},{"html":"\u003cp\u003eThis command conforms to the SQL standard, with these \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e extensions:\u003c/p\u003e\u003cdiv class=\"itemizedlist\"\u003e\u003cul class=\"itemizedlist\"\u003e\u003cli class=\"listitem\"\u003e\u003cp\u003eThe standard only allows one routine to be dropped per command.\u003c/p\u003e\u003c/li\u003e\u003cli class=\"listitem\"\u003e\u003cp\u003eThe \u003ccode class=\"literal\"\u003eIF EXISTS\u003c/code\u003e option is an extension.\u003c/p\u003e\u003c/li\u003e\u003cli class=\"listitem\"\u003e\u003cp\u003eThe ability to specify argument modes and names is an extension, and the lookup rules differ when modes are given.\u003c/p\u003e\u003c/li\u003e\u003cli class=\"listitem\"\u003e\u003cp\u003eUser-definable aggregate functions are an extension.\u003c/p\u003e\u003c/li\u003e\u003c/ul\u003e\u003c/div\u003e","key":"compatibility","title":"Compatibility"},{"html":"\u003cspan class=\"simplelist\"\u003e\u003ca href=\"/wiki/sql/drop-aggregate/?v=18\" title=\"DROP AGGREGATE\"\u003e\u003cspan class=\"refentrytitle\"\u003eDROP AGGREGATE\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/drop-function/?v=18\" title=\"DROP FUNCTION\"\u003e\u003cspan class=\"refentrytitle\"\u003eDROP FUNCTION\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/drop-procedure/?v=18\" title=\"DROP PROCEDURE\"\u003e\u003cspan class=\"refentrytitle\"\u003eDROP PROCEDURE\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/alter-routine/?v=18\" title=\"ALTER ROUTINE\"\u003e\u003cspan class=\"refentrytitle\"\u003eALTER ROUTINE\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e\u003cp\u003eNote that there is no \u003ccode class=\"literal\"\u003eCREATE ROUTINE\u003c/code\u003e command.\u003c/p\u003e","key":"see_also","title":"See Also"}],"sections_same_as":"","slug":"18","synopsis_html":"DROP ROUTINE [ IF EXISTS ] \u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e [ ( [ [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003eargmode\u003c/code\u003e\u003c/em\u003e ] [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003eargname\u003c/code\u003e\u003c/em\u003e ] \u003cem class=\"replaceable\"\u003e\u003ccode\u003eargtype\u003c/code\u003e\u003c/em\u003e [, ...] ] ) ] [, ...]\n    [ CASCADE | RESTRICT ]","synopsis_text":"DROP ROUTINE [ IF EXISTS ] name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ] [, ...]\n[ CASCADE | RESTRICT ]"},"ManualEvidence":{},"MeasuredEvidence":{}},"Text":{"Collection":"sql","Key":"drop-routine","SourceDatabase":"pgweb","Version":"18","Locale":"zh-Hans","Title":"DROP ROUTINE","Summary":"移除一个例程","BodyHTML":"\u003cpre\u003eDROP ROUTINE [ IF EXISTS ] name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ] [, ...]\n[ CASCADE | RESTRICT ]\u003c/pre\u003e\u003csection\u003e\u003ch2\u003e描述\u003c/h2\u003e\u003cp\u003e\u003ccode\u003eDROP ROUTINE\u003c/code\u003e移除一个或多个现有例程的定义。术语\u003cspan\u003e“\u003cspan\u003e例程\u003c/span\u003e”\u003c/span\u003e包括聚合函数、普通函数和过程。关于参数的说明、更多示例以及进一步细节，请分别参见\u003ca href=\"/docs/18/sql-dropaggregate.html\" title=\"DROP AGGREGATE\" rel=\"nofollow\"\u003e\u003cspan\u003eDROP AGGREGATE\u003c/span\u003e\u003c/a\u003e、\u003ca href=\"/docs/18/sql-dropfunction.html\" title=\"DROP FUNCTION\" rel=\"nofollow\"\u003e\u003cspan\u003eDROP FUNCTION\u003c/span\u003e\u003c/a\u003e和\u003ca href=\"/docs/18/sql-dropprocedure.html\" title=\"DROP PROCEDURE\" rel=\"nofollow\"\u003e\u003cspan\u003eDROP PROCEDURE\u003c/span\u003e\u003c/a\u003e。\u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e注解\u003c/h2\u003e\u003cp\u003e\u003ccode\u003eDROP ROUTINE\u003c/code\u003e所使用的查找规则，从根本上说与 \u003ccode\u003eDROP PROCEDURE\u003c/code\u003e相同；特别是，\u003ccode\u003eDROP ROUTINE\u003c/code\u003e与该命令一样：如果参数列表中没有 \u003cem\u003e\u003ccode\u003eargmode\u003c/code\u003e\u003c/em\u003e标记，就会认为它可能采用 SQL 标准的定义，即将\u003ccode\u003eOUT\u003c/code\u003e参数也包含在列表中。（\u003ccode\u003eDROP AGGREGATE\u003c/code\u003e和\u003ccode\u003eDROP FUNCTION\u003c/code\u003e不会这样。）\u003c/p\u003e\u003cp\u003e在某些不同种类的例程共享同一名称的情况下，\u003ccode\u003eDROP ROUTINE\u003c/code\u003e 可能会因为歧义错误而失败，而更具体的命令（\u003ccode\u003eDROP FUNCTION\u003c/code\u003e等）则可以工作。更仔细地指定参数类型列表，同样可以解决这类问题。\u003c/p\u003e\u003cp\u003e这些查找规则也被其他作用于现有例程的命令使用，例如 \u003ccode\u003eALTER ROUTINE\u003c/code\u003e和\u003ccode\u003eCOMMENT ON ROUTINE\u003c/code\u003e。\u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e示例\u003c/h2\u003e\u003cp\u003e删除参数类型为\u003ccode\u003einteger\u003c/code\u003e的例程\u003ccode\u003efoo\u003c/code\u003e：\u003c/p\u003e\u003cpre\u003eDROP ROUTINE foo(integer);\n\u003c/pre\u003e\u003cp\u003e不管\u003ccode\u003efoo\u003c/code\u003e是聚合函数、普通函数还是过程，这条命令都可以工作。\u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e兼容性\u003c/h2\u003e\u003cp\u003e此命令符合 SQL 标准，但有以下\u003cspan\u003ePostgreSQL\u003c/span\u003e扩展：\u003c/p\u003e\u003cdiv\u003e\u003cul\u003e\u003cli\u003e\u003cp\u003e标准每条命令只允许删除一个例程。\u003c/p\u003e\u003c/li\u003e\u003cli\u003e\u003cp\u003e\u003ccode\u003eIF EXISTS\u003c/code\u003e选项是扩展。\u003c/p\u003e\u003c/li\u003e\u003cli\u003e\u003cp\u003e允许指定参数模式和参数名是扩展，而且在给出模式时查找规则也有所不同。\u003c/p\u003e\u003c/li\u003e\u003cli\u003e\u003cp\u003e用户可定义的聚合函数是扩展。\u003c/p\u003e\u003c/li\u003e\u003c/ul\u003e\u003c/div\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e另见\u003c/h2\u003e\u003cspan\u003e\u003ca href=\"/wiki/sql/drop-aggregate/?v=18\" title=\"DROP AGGREGATE\" rel=\"nofollow\"\u003e\u003cspan\u003eDROP AGGREGATE\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/drop-function/?v=18\" title=\"DROP FUNCTION\" rel=\"nofollow\"\u003e\u003cspan\u003eDROP FUNCTION\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/drop-procedure/?v=18\" title=\"DROP PROCEDURE\" rel=\"nofollow\"\u003e\u003cspan\u003eDROP PROCEDURE\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/alter-routine/?v=18\" title=\"ALTER ROUTINE\" rel=\"nofollow\"\u003e\u003cspan\u003eALTER ROUTINE\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e\u003cp\u003e注意，没有\u003ccode\u003eCREATE ROUTINE\u003c/code\u003e命令。\u003c/p\u003e\u003c/section\u003e","SourceRevision":"1b5ca64c","ContentHash":"7d444cb420d38df53b2e276e5f2d0f2da17cbc96b74ea581da0d9bec84a5e761","Payload":{"purpose_zh":"移除一个例程","sections":[{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eDROP ROUTINE\u003c/code\u003e移除一个或多个现有例程的定义。术语\u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003e例程\u003c/span\u003e”\u003c/span\u003e包括聚合函数、普通函数和过程。关于参数的说明、更多示例以及进一步细节，请分别参见\u003ca href=\"/docs/18/sql-dropaggregate.html\" title=\"DROP AGGREGATE\"\u003e\u003cspan class=\"refentrytitle\"\u003eDROP AGGREGATE\u003c/span\u003e\u003c/a\u003e、\u003ca href=\"/docs/18/sql-dropfunction.html\" title=\"DROP FUNCTION\"\u003e\u003cspan class=\"refentrytitle\"\u003eDROP FUNCTION\u003c/span\u003e\u003c/a\u003e和\u003ca href=\"/docs/18/sql-dropprocedure.html\" title=\"DROP PROCEDURE\"\u003e\u003cspan class=\"refentrytitle\"\u003eDROP PROCEDURE\u003c/span\u003e\u003c/a\u003e。\u003c/p\u003e","key":"description","title":"描述"},{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eDROP ROUTINE\u003c/code\u003e所使用的查找规则，从根本上说与 \u003ccode class=\"command\"\u003eDROP PROCEDURE\u003c/code\u003e相同；特别是，\u003ccode class=\"command\"\u003eDROP ROUTINE\u003c/code\u003e与该命令一样：如果参数列表中没有 \u003cem class=\"replaceable\"\u003e\u003ccode\u003eargmode\u003c/code\u003e\u003c/em\u003e标记，就会认为它可能采用 SQL 标准的定义，即将\u003ccode class=\"literal\"\u003eOUT\u003c/code\u003e参数也包含在列表中。（\u003ccode class=\"command\"\u003eDROP AGGREGATE\u003c/code\u003e和\u003ccode class=\"command\"\u003eDROP FUNCTION\u003c/code\u003e不会这样。）\u003c/p\u003e\u003cp\u003e在某些不同种类的例程共享同一名称的情况下，\u003ccode class=\"command\"\u003eDROP ROUTINE\u003c/code\u003e 可能会因为歧义错误而失败，而更具体的命令（\u003ccode class=\"command\"\u003eDROP FUNCTION\u003c/code\u003e等）则可以工作。更仔细地指定参数类型列表，同样可以解决这类问题。\u003c/p\u003e\u003cp\u003e这些查找规则也被其他作用于现有例程的命令使用，例如 \u003ccode class=\"command\"\u003eALTER ROUTINE\u003c/code\u003e和\u003ccode class=\"command\"\u003eCOMMENT ON ROUTINE\u003c/code\u003e。\u003c/p\u003e","key":"notes","title":"注解"},{"html":"\u003cp\u003e删除参数类型为\u003ccode class=\"type\"\u003einteger\u003c/code\u003e的例程\u003ccode class=\"literal\"\u003efoo\u003c/code\u003e：\u003c/p\u003e\u003cpre class=\"programlisting\"\u003eDROP ROUTINE foo(integer);\n\u003c/pre\u003e\u003cp\u003e不管\u003ccode class=\"literal\"\u003efoo\u003c/code\u003e是聚合函数、普通函数还是过程，这条命令都可以工作。\u003c/p\u003e","key":"examples","title":"示例"},{"html":"\u003cp\u003e此命令符合 SQL 标准，但有以下\u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e扩展：\u003c/p\u003e\u003cdiv class=\"itemizedlist\"\u003e\u003cul class=\"itemizedlist\"\u003e\u003cli class=\"listitem\"\u003e\u003cp\u003e标准每条命令只允许删除一个例程。\u003c/p\u003e\u003c/li\u003e\u003cli class=\"listitem\"\u003e\u003cp\u003e\u003ccode class=\"literal\"\u003eIF EXISTS\u003c/code\u003e选项是扩展。\u003c/p\u003e\u003c/li\u003e\u003cli class=\"listitem\"\u003e\u003cp\u003e允许指定参数模式和参数名是扩展，而且在给出模式时查找规则也有所不同。\u003c/p\u003e\u003c/li\u003e\u003cli class=\"listitem\"\u003e\u003cp\u003e用户可定义的聚合函数是扩展。\u003c/p\u003e\u003c/li\u003e\u003c/ul\u003e\u003c/div\u003e","key":"compatibility","title":"兼容性"},{"html":"\u003cspan class=\"simplelist\"\u003e\u003ca href=\"/wiki/sql/drop-aggregate/?v=18\" title=\"DROP AGGREGATE\"\u003e\u003cspan class=\"refentrytitle\"\u003eDROP AGGREGATE\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/drop-function/?v=18\" title=\"DROP FUNCTION\"\u003e\u003cspan class=\"refentrytitle\"\u003eDROP FUNCTION\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/drop-procedure/?v=18\" title=\"DROP PROCEDURE\"\u003e\u003cspan class=\"refentrytitle\"\u003eDROP PROCEDURE\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/alter-routine/?v=18\" title=\"ALTER ROUTINE\"\u003e\u003cspan class=\"refentrytitle\"\u003eALTER ROUTINE\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e\u003cp\u003e注意，没有\u003ccode class=\"literal\"\u003eCREATE ROUTINE\u003c/code\u003e命令。\u003c/p\u003e","key":"see_also","title":"另见"}],"sections_same_as":"","synopsis_html":"DROP ROUTINE [ IF EXISTS ] \u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e [ ( [ [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003eargmode\u003c/code\u003e\u003c/em\u003e ] [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003eargname\u003c/code\u003e\u003c/em\u003e ] \u003cem class=\"replaceable\"\u003e\u003ccode\u003eargtype\u003c/code\u003e\u003c/em\u003e [, ...] ] ) ] [, ...]\n    [ CASCADE | RESTRICT ]","synopsis_text":"DROP ROUTINE [ IF EXISTS ] name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ] [, ...]\n[ CASCADE | RESTRICT ]"}},"RequestedLocale":"zh-Hans","Fallback":false,"Versions":["11","12","13","14","15","16","17","18","19","20"],"Locales":["en","zh-Hans"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
