Share via


DROP FUNCTION

Gilt für:durch Häkchen mit „Ja“ markiert Databricks SQL durch Häkchen mit „Ja“ markiert Databricks Runtime

Löscht eine temporäre oder permanente benutzerdefinierte Funktion (User-Defined Function, UDF). Um eine Funktion zu löschen, müssen Sie deren Besitzer oder der Besitzer des Schemas, Katalogs oder Metastores sein, in dem sich die Funktion befindet.

Syntax

DROP [ TEMPORARY ] FUNCTION [ IF EXISTS ] function_name

Parameter

  • function_name

    Name einer vorhandenen Funktion. Der Funktionsname kann optional mit einem Schemanamen qualifiziert werden.

  • TEMPORARY

    Wird zum Löschen einer TEMPORARY-Funktion verwendet.

  • IF EXISTS

    Wird dieser Parameter angegeben, wird keine Ausnahme ausgelöst, wenn die Funktion nicht vorhanden ist.

Beispiele

-- Create a permanent function `hello`
> CREATE FUNCTION hello() RETURNS STRING RETURN 'Hello World!';

-- Create a temporary function `hello`
> CREATE TEMPORARY FUNCTION hello() RETURNS STRING RETURN 'Good morning!';

-- List user functions
> SHOW USER FUNCTIONS;
  default.hello
          hello

-- Drop a permanent function
> DROP FUNCTION hello;

-- Try to drop a permanent function which is not present
> DROP FUNCTION hello;
Function 'default.hello' not found in schema 'default'

-- List the functions after dropping, it should list only temporary function
> SHOW USER FUNCTIONS;
 hello

-- Drop a temporary function if exists
> DROP TEMPORARY FUNCTION IF EXISTS hello;