{"id":1275,"date":"2024-12-26T10:10:12","date_gmt":"2024-12-26T03:10:12","guid":{"rendered":"https:\/\/www.pgtutorial.com\/?page_id=1275"},"modified":"2025-01-03T11:14:56","modified_gmt":"2025-01-03T04:14:56","slug":"postgresql-drop-function","status":"publish","type":"page","link":"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-drop-function\/","title":{"rendered":"PostgreSQL DROP FUNCTION Statement"},"content":{"rendered":"\n<p><strong>Summary<\/strong>: In this tutorial, you&#8217;ll learn how to use the PostgreSQL <code>DROP FUNCTION<\/code> statement to drop a function from the database.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='getting-started-with-the-postgresql-drop-function-statement'>Getting Started with the PostgreSQL DROP FUNCTION Statement <a href=\"#getting-started-with-the-postgresql-drop-function-statement\" class=\"anchor\" id=\"getting-started-with-the-postgresql-drop-function-statement\" title=\"Anchor for Getting Started with the PostgreSQL DROP FUNCTION Statement\">#<\/a><\/h2>\n\n\n\n<p>The <code>DROP FUNCTION<\/code> statement allows you to remove a <a href=\"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-create-function\/\">user-defined function<\/a> permanently from the database.<\/p>\n\n\n\n<p>Here&#8217;s the syntax of the <code>DROP FUNCTION<\/code> statement:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">DROP<\/span> <span class=\"hljs-keyword\">FUNCTION<\/span> &#91;<span class=\"hljs-keyword\">IF<\/span> <span class=\"hljs-keyword\">EXISTS<\/span>] function_name(parameters);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>In this syntax:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>First, specify the function name after the <code>DROP FUNCTION<\/code> keyword with a list of parameters.<\/li>\n\n\n\n<li>Second, use the <code>IF EXISTS<\/code> clause if you want to drop the function conditionally, only if it exists.<\/li>\n<\/ul>\n\n\n\n<p>If a function has dependent objects like operators and triggers, you cannot drop it.<\/p>\n\n\n\n<p>Fortunately, you can drop the function and its dependent objects by using the <code>CASCADE<\/code> option explicitly:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">DROP<\/span> <span class=\"hljs-keyword\">FUNCTION<\/span> &#91;<span class=\"hljs-keyword\">IF<\/span> <span class=\"hljs-keyword\">EXISTS<\/span>] function_name(parameters) <span class=\"hljs-keyword\">CASCADE<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The <code>RESTRICT<\/code> option prevents you from removing a function with dependent objects. The <code>DROP FUNCTION<\/code> statement uses the <code>RESTRICT<\/code> option by default.<\/p>\n\n\n\n<p>To remove multiple functions at once, you can specify a comma-separated list of function names after the <code>DROP FUNCTION<\/code> keyword:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">DROP<\/span> <span class=\"hljs-keyword\">FUNCTION<\/span> \n    function_name1(parameter), \n    function_name2(parameter), ...;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\" id='postgresql-drop-function-statement-examples'>PostgreSQL DROP FUNCTION Statement Examples <a href=\"#postgresql-drop-function-statement-examples\" class=\"anchor\" id=\"postgresql-drop-function-statement-examples\" title=\"Anchor for PostgreSQL DROP FUNCTION Statement Examples\">#<\/a><\/h2>\n\n\n\n<p>Let&#8217;s <a href=\"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-create-function\/\">create some functions<\/a> and demonstrate the <code>DROP FUNCTION<\/code> statement to remove them.<\/p>\n\n\n\n<p>First, create a function that returns the total inventory quantity:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">CREATE<\/span> <span class=\"hljs-keyword\">OR REPLACE<\/span> <span class=\"hljs-keyword\">FUNCTION<\/span> get_total_inventory() \n    <span class=\"hljs-keyword\">RETURNS<\/span> <span class=\"hljs-type\">int<\/span> \n<span class=\"hljs-keyword\">AS<\/span> \n$$<span class=\"pgsql\">\n    <span class=\"hljs-keyword\">SELECT<\/span> sum(quantity) <span class=\"hljs-keyword\">FROM<\/span> inventories;\n$$<\/span> <span class=\"hljs-keyword\">LANGUAGE<\/span> <span class=\"hljs-keyword\">sql<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><a href=\"https:\/\/www.pgtutorial.com\/playground\/?q=Q1JFQVRFIE9SIFJFUExBQ0UgRlVOQ1RJT04gZ2V0X3RvdGFsX2ludmVudG9yeSgpIFJFVFVSTlMgaW50IEFTICQkIFNFTEVDVCBzdW0ocXVhbnRpdHkpIEZST00gaW52ZW50b3JpZXM7ICQkIExBTkdVQUdFIHNxbDs%3D\" target=\"_blank\" rel=\"noreferrer noopener\">Try it<\/a><\/p>\n\n\n\n<p>Second, create a function that returns the product, warehouse, and inventory quantity within a range:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">CREATE<\/span> <span class=\"hljs-keyword\">OR REPLACE<\/span> <span class=\"hljs-keyword\">FUNCTION<\/span> get_inventory(min_qty <span class=\"hljs-type\">int<\/span>, max_qty <span class=\"hljs-type\">int<\/span>) \n<span class=\"hljs-keyword\">RETURNS<\/span> <span class=\"hljs-keyword\">TABLE<\/span> (product <span class=\"hljs-type\">varchar<\/span>, warehouse <span class=\"hljs-type\">varchar<\/span>, quantity <span class=\"hljs-type\">int<\/span>) \n<span class=\"hljs-keyword\">AS<\/span> \n$$<span class=\"pgsql\">\n    <span class=\"hljs-keyword\">SELECT<\/span> product_name, warehouse_name, quantity \n    <span class=\"hljs-keyword\">FROM<\/span> inventories\n    <span class=\"hljs-keyword\">JOIN<\/span> products <span class=\"hljs-keyword\">USING<\/span> (product_id) \n    <span class=\"hljs-keyword\">JOIN<\/span> warehouses <span class=\"hljs-keyword\">USING<\/span> (warehouse_id)\n    <span class=\"hljs-keyword\">WHERE<\/span> quantity &gt;= min_qty <span class=\"hljs-keyword\">AND<\/span> quantity &lt;= max_qty;\n$$<\/span> <span class=\"hljs-keyword\">LANGUAGE<\/span> <span class=\"hljs-keyword\">sql<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><a href=\"https:\/\/www.pgtutorial.com\/playground\/?q=Q1JFQVRFIE9SIFJFUExBQ0UgRlVOQ1RJT04gZ2V0X2ludmVudG9yeShtaW5fcXR5IGludCwgbWF4X3F0eSBpbnQpIFJFVFVSTlMgVEFCTEUgKHByb2R1Y3QgdmFyY2hhciwgd2FyZWhvdXNlIHZhcmNoYXIsIHF1YW50aXR5IGludCkgQVMgJCQgU0VMRUNUIHByb2R1Y3RfbmFtZSwgd2FyZWhvdXNlX25hbWUsIHF1YW50aXR5IEZST00gaW52ZW50b3JpZXMgSk9JTiBwcm9kdWN0cyBVU0lORyAocHJvZHVjdF9pZCkgSk9JTiB3YXJlaG91c2VzIFVTSU5HICh3YXJlaG91c2VfaWQpIFdIRVJFIHF1YW50aXR5ID49IG1pbl9xdHkgQU5EIHF1YW50aXR5IDw9IG1heF9xdHk7ICQkIExBTkdVQUdFIHNxbDs%3D\" target=\"_blank\" rel=\"noreferrer noopener\">Try it<\/a><\/p>\n\n\n\n<p>Third, create an overloaded function to return inventory at a specific quantity:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">CREATE<\/span> <span class=\"hljs-keyword\">OR REPLACE<\/span> <span class=\"hljs-keyword\">FUNCTION<\/span> get_inventory(qty <span class=\"hljs-type\">int<\/span>) \n<span class=\"hljs-keyword\">RETURNS<\/span> <span class=\"hljs-keyword\">TABLE<\/span> (product <span class=\"hljs-type\">varchar<\/span>, warehouse <span class=\"hljs-type\">varchar<\/span>, quantity <span class=\"hljs-type\">int<\/span>) \n<span class=\"hljs-keyword\">AS<\/span> $$<span class=\"pgsql\">\n    <span class=\"hljs-keyword\">SELECT<\/span> product_name, warehouse_name, quantity \n    <span class=\"hljs-keyword\">FROM<\/span> inventories\n    <span class=\"hljs-keyword\">JOIN<\/span> products <span class=\"hljs-keyword\">USING<\/span> (product_id) \n    <span class=\"hljs-keyword\">JOIN<\/span> warehouses <span class=\"hljs-keyword\">USING<\/span> (warehouse_id)\n    <span class=\"hljs-keyword\">WHERE<\/span> quantity = qty;\n$$<\/span> <span class=\"hljs-keyword\">LANGUAGE<\/span> <span class=\"hljs-keyword\">sql<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><a href=\"https:\/\/www.pgtutorial.com\/playground\/?q=Q1JFQVRFIE9SIFJFUExBQ0UgRlVOQ1RJT04gZ2V0X2ludmVudG9yeShxdHkgaW50KSBSRVRVUk5TIFRBQkxFIChwcm9kdWN0IHZhcmNoYXIsIHdhcmVob3VzZSB2YXJjaGFyLCBxdWFudGl0eSBpbnQpIEFTICQkIFNFTEVDVCBwcm9kdWN0X25hbWUsIHdhcmVob3VzZV9uYW1lLCBxdWFudGl0eSBGUk9NIGludmVudG9yaWVzIEpPSU4gcHJvZHVjdHMgVVNJTkcgKHByb2R1Y3RfaWQpIEpPSU4gd2FyZWhvdXNlcyBVU0lORyAod2FyZWhvdXNlX2lkKSBXSEVSRSBxdWFudGl0eSA9IHF0eTsgJCQgTEFOR1VBR0Ugc3FsOw%3D%3D\" target=\"_blank\" rel=\"noreferrer noopener\">Try it<\/a><\/p>\n\n\n\n<p>Finally, create two simple functions that add and subtract two integers:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">CREATE<\/span> <span class=\"hljs-keyword\">OR REPLACE<\/span> <span class=\"hljs-keyword\">FUNCTION<\/span> <span class=\"hljs-keyword\">add<\/span>(a <span class=\"hljs-type\">int<\/span>, b <span class=\"hljs-type\">int<\/span>) \n<span class=\"hljs-keyword\">RETURNS<\/span> <span class=\"hljs-type\">INT<\/span> \n<span class=\"hljs-keyword\">AS<\/span> \n$$<span class=\"pgsql\">\n    <span class=\"hljs-keyword\">SELECT<\/span> a + b;\n$$<\/span> <span class=\"hljs-keyword\">LANGUAGE<\/span> <span class=\"hljs-keyword\">SQL<\/span>;\n\n<span class=\"hljs-keyword\">CREATE<\/span> <span class=\"hljs-keyword\">OR REPLACE<\/span> <span class=\"hljs-keyword\">FUNCTION<\/span> subtract(a <span class=\"hljs-type\">int<\/span>, b <span class=\"hljs-type\">int<\/span>) \n<span class=\"hljs-keyword\">RETURNS<\/span> <span class=\"hljs-type\">INT<\/span> \n<span class=\"hljs-keyword\">AS<\/span>\n$$<span class=\"pgsql\">\n    <span class=\"hljs-keyword\">SELECT<\/span> a - b;\n$$<\/span> <span class=\"hljs-keyword\">LANGUAGE<\/span> <span class=\"hljs-keyword\">SQL<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><a href=\"https:\/\/www.pgtutorial.com\/playground\/?q=Q1JFQVRFIE9SIFJFUExBQ0UgRlVOQ1RJT04gYWRkKGEgaW50LCBiIGludCkgUkVUVVJOUyBJTlQgQVMgJCQgU0VMRUNUIGEgKyBiOyAkJCBMQU5HVUFHRSBTUUw7IENSRUFURSBPUiBSRVBMQUNFIEZVTkNUSU9OIHN1YnRyYWN0KGEgaW50LCBiIGludCkgUkVUVVJOUyBJTlQgQVMgJCQgU0VMRUNUIGEgLSBiOyAkJCBMQU5HVUFHRSBTUUw7\" target=\"_blank\" rel=\"noreferrer noopener\">Try it<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id='basic-postgresql-drop-function-statement-example'>Basic PostgreSQL DROP FUNCTION statement example <a href=\"#basic-postgresql-drop-function-statement-example\" class=\"anchor\" id=\"basic-postgresql-drop-function-statement-example\" title=\"Anchor for Basic PostgreSQL DROP FUNCTION statement example\">#<\/a><\/h3>\n\n\n\n<p>The following <code>DROP FUNCTION<\/code> statement removes the <code>get_total_inventory<\/code> function:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">DROP<\/span> <span class=\"hljs-keyword\">FUNCTION<\/span> <span class=\"hljs-keyword\">IF<\/span> <span class=\"hljs-keyword\">EXISTS<\/span> get_total_inventory;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><a href=\"https:\/\/www.pgtutorial.com\/playground\/?q=RFJPUCBGVU5DVElPTiBnZXRfdG90YWxfaW52ZW50b3J5Ow%3D%3D\" target=\"_blank\" rel=\"noreferrer noopener\">Try it<\/a><\/p>\n\n\n\n<p>Since no other functions have the same name as the <code>get_total_inventory<\/code> function, we don&#8217;t need to specify the parameter list.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id='dropping-an-overloaded-function-example'>Dropping an Overloaded Function Example <a href=\"#dropping-an-overloaded-function-example\" class=\"anchor\" id=\"dropping-an-overloaded-function-example\" title=\"Anchor for Dropping an Overloaded Function Example\">#<\/a><\/h3>\n\n\n\n<p>The following <code>DROP FUNCTION<\/code> statement attempts to drop the <code>get_inventory<\/code> function:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-9\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">DROP<\/span> <span class=\"hljs-keyword\">FUNCTION<\/span> <span class=\"hljs-keyword\">IF<\/span> <span class=\"hljs-keyword\">EXISTS<\/span> get_inventory;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-9\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><a href=\"https:\/\/www.pgtutorial.com\/playground\/?q=RFJPUCBGVU5DVElPTiBnZXRfaW52ZW50b3J5Ow%3D%3D\" target=\"_blank\" rel=\"noreferrer noopener\">Try it<\/a><\/p>\n\n\n\n<p>It issues an error because two functions have the same name <code>get_inventory<\/code>:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-10\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-type\">name<\/span> \"get_inventory\" <span class=\"hljs-keyword\">is<\/span> <span class=\"hljs-keyword\">not<\/span> <span class=\"hljs-keyword\">unique<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-10\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>To fix it, you need to specify the parameter list explicitly so PostgreSQL knows which function you want to drop.<\/p>\n\n\n\n<p>For example, the following statement drops the <code>get_inventory<\/code> function that accepts an integer (int) parameter:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-11\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">DROP<\/span> <span class=\"hljs-keyword\">FUNCTION<\/span> <span class=\"hljs-keyword\">IF<\/span> <span class=\"hljs-keyword\">EXISTS<\/span> get_inventory(<span class=\"hljs-type\">int<\/span>);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-11\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><a href=\"https:\/\/www.pgtutorial.com\/playground\/?q=RFJPUCBGVU5DVElPTiBJRiBFWElTVFMgZ2V0X2ludmVudG9yeShpbnQpOw%3D%3D\" target=\"_blank\" rel=\"noreferrer noopener\">Try it<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id='dropping-multiple-functions-example'>Dropping Multiple Functions Example <a href=\"#dropping-multiple-functions-example\" class=\"anchor\" id=\"dropping-multiple-functions-example\" title=\"Anchor for Dropping Multiple Functions Example\">#<\/a><\/h3>\n\n\n\n<p>The following example uses the <code>DROP FUNCTION<\/code> statement to drop two functions at once:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-12\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">DROP<\/span> <span class=\"hljs-keyword\">FUNCTION<\/span> <span class=\"hljs-keyword\">add<\/span>, subtract;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-12\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><a href=\"https:\/\/www.pgtutorial.com\/playground\/?q=RFJPUCBGVU5DVElPTiBhZGQsIHN1YnRyYWN0Ow%3D%3D\" target=\"_blank\" rel=\"noreferrer noopener\">Try it<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='summary'>Summary <a href=\"#summary\" class=\"anchor\" id=\"summary\" title=\"Anchor for Summary\">#<\/a><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use the PostgreSQL <code>DROP FUNCTION<\/code> to remove a function from a database.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id='quiz'>Quiz <a href=\"#quiz\" class=\"anchor\" id=\"quiz\" title=\"Anchor for Quiz\">#<\/a><\/h2>\n\n\n\n<iframe loading=\"lazy\"\n  name=\"quiz\"\n  src=\"\/quiz\/?quiz=drop-function\"\n  height=\"700\"\n  width=\"600\"\n  class=\"iframe\"\n><\/iframe>\n<div class=\"helpful-block-content\" data-title=\"\">\n\t<header>\n\t\t<div class=\"wth-question\">Was this tutorial helpful ?<\/div>\n\t\t<div class=\"wth-thumbs\">\n\t\t\t<button\n\t\t\t\tdata-post=\"1275\"\n\t\t\t\tdata-post-url=\"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-drop-function\/\"\n\t\t\t\tdata-post-title=\"PostgreSQL DROP FUNCTION Statement\"\n\t\t\t\tdata-response=\"1\"\n\t\t\t\tclass=\"wth-btn-rounded wth-yes-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t\tclass=\"feather feather-thumbs-up block w-full h-full\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> Yes <\/span>\n\t\t\t<\/button>\n\n\t\t\t<button\n\t\t\t\tdata-response=\"0\"\n\t\t\t\tdata-post=\"1275\"\n\t\t\t\tdata-post-url=\"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-drop-function\/\"\n\t\t\t\tdata-post-title=\"PostgreSQL DROP FUNCTION Statement\"\n\t\t\t\tclass=\"wth-btn-rounded wth-no-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> No <\/span>\n\t\t\t<\/button>\n\t\t<\/div>\n\t<\/header>\n\n\t<div class=\"wth-form hidden\">\n\t\t<div class=\"wth-form-wrapper\">\n\t\t\t<div class=\"wth-title\"><\/div>\n\t\t\t\n\t\t\t<textarea class=\"wth-message\"><\/textarea>\n\n\t\t\t<button class=\"btn btn-primary wth-btn-submit\">Send<\/button>\n\t\t\t<button class=\"btn wth-btn-cancel\">Cancel<\/button>\n\t\t\n\t\t<\/div>\n\t<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Summary: In this tutorial, you&#8217;ll learn how to use the PostgreSQL DROP FUNCTION statement to drop a function from the database. Getting Started with the PostgreSQL DROP FUNCTION Statement # The DROP FUNCTION statement allows you to remove a user-defined function permanently from the database. Here&#8217;s the syntax of the DROP FUNCTION statement: In this [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":13,"menu_order":79,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1275","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>PostgreSQL DROP FUNCTION Statement<\/title>\n<meta name=\"description\" content=\"In this tutorial, you&#039;ll learn how to use the PostgreSQL DROP FUNCTION statement to drop a function from the database.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-drop-function\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PostgreSQL DROP FUNCTION Statement\" \/>\n<meta property=\"og:description\" content=\"In this tutorial, you&#039;ll learn how to use the PostgreSQL DROP FUNCTION statement to drop a function from the database.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-drop-function\/\" \/>\n<meta property=\"og:site_name\" content=\"PostgreSQL Tutorial\" \/>\n<meta property=\"article:modified_time\" content=\"2025-01-03T04:14:56+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.pgtutorial.com\\\/postgresql-tutorial\\\/postgresql-drop-function\\\/\",\"url\":\"https:\\\/\\\/www.pgtutorial.com\\\/postgresql-tutorial\\\/postgresql-drop-function\\\/\",\"name\":\"PostgreSQL DROP FUNCTION Statement\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.pgtutorial.com\\\/#website\"},\"datePublished\":\"2024-12-26T03:10:12+00:00\",\"dateModified\":\"2025-01-03T04:14:56+00:00\",\"description\":\"In this tutorial, you'll learn how to use the PostgreSQL DROP FUNCTION statement to drop a function from the database.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.pgtutorial.com\\\/postgresql-tutorial\\\/postgresql-drop-function\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.pgtutorial.com\\\/postgresql-tutorial\\\/postgresql-drop-function\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.pgtutorial.com\\\/postgresql-tutorial\\\/postgresql-drop-function\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.pgtutorial.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PostgreSQL Tutorial\",\"item\":\"https:\\\/\\\/www.pgtutorial.com\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"PostgreSQL DROP FUNCTION Statement\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.pgtutorial.com\\\/#website\",\"url\":\"https:\\\/\\\/www.pgtutorial.com\\\/\",\"name\":\"PostgreSQL Tutorial\",\"description\":\"Learn PostgreSQL from Scratch\",\"alternateName\":\"PostgreSQL\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.pgtutorial.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"PostgreSQL DROP FUNCTION Statement","description":"In this tutorial, you'll learn how to use the PostgreSQL DROP FUNCTION statement to drop a function from the database.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-drop-function\/","og_locale":"en_US","og_type":"article","og_title":"PostgreSQL DROP FUNCTION Statement","og_description":"In this tutorial, you'll learn how to use the PostgreSQL DROP FUNCTION statement to drop a function from the database.","og_url":"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-drop-function\/","og_site_name":"PostgreSQL Tutorial","article_modified_time":"2025-01-03T04:14:56+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-drop-function\/","url":"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-drop-function\/","name":"PostgreSQL DROP FUNCTION Statement","isPartOf":{"@id":"https:\/\/www.pgtutorial.com\/#website"},"datePublished":"2024-12-26T03:10:12+00:00","dateModified":"2025-01-03T04:14:56+00:00","description":"In this tutorial, you'll learn how to use the PostgreSQL DROP FUNCTION statement to drop a function from the database.","breadcrumb":{"@id":"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-drop-function\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-drop-function\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-drop-function\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.pgtutorial.com\/"},{"@type":"ListItem","position":2,"name":"PostgreSQL Tutorial","item":"https:\/\/www.pgtutorial.com\/"},{"@type":"ListItem","position":3,"name":"PostgreSQL DROP FUNCTION Statement"}]},{"@type":"WebSite","@id":"https:\/\/www.pgtutorial.com\/#website","url":"https:\/\/www.pgtutorial.com\/","name":"PostgreSQL Tutorial","description":"Learn PostgreSQL from Scratch","alternateName":"PostgreSQL","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.pgtutorial.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/pages\/1275","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/comments?post=1275"}],"version-history":[{"count":5,"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/pages\/1275\/revisions"}],"predecessor-version":[{"id":1398,"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/pages\/1275\/revisions\/1398"}],"up":[{"embeddable":true,"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/pages\/13"}],"wp:attachment":[{"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/media?parent=1275"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}