Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PostgreSQL: How to DROP FUNCTION IF EXISTS without specifying parameters?

People also ask

What is drop cascade in PostgreSQL?

The CASCADE option allows you to remove the table and its dependent objects. The RESTRICT option rejects the removal if there is any object depends on the table. The RESTRICT option is the default if you don't explicitly specify it in the DROP TABLE statement.

How do you drop a function in PL SQL?

The syntax to a drop a function in Oracle is: DROP FUNCTION function_name; function_name.

How do I replace a function in PostgreSQL?

In PostgreSQL, the REPLACE function is used to search and replace all occurrences of a string with a new one. Syntax: REPLACE(source, old_text, new_text ); Let's analyze the above syntax: The source is a string where you want to replace the existing string.


In Postgres functions can be overloaded, so parameters are necessary to distinguish overloaded functions. To unambiguously identify a function you can put only types of its parameters.

DROP FUNCTION IF EXISTS Foo(INT);

As of Postgres 10 you can drop functions by name only, as long as the names are unique to their schema.

Example:

drop function if exists Foo;

Documentation here.