Dela via


DROP FUNCTION

Gäller för:markerad ja Databricks SQL markerad ja Databricks Runtime

Släpper en tillfällig eller permanent användardefinierad funktion (UDF). Om du vill släppa en funktion måste du ha MANAGE behörighet för funktionen, vara dess ägare eller ägare av schema, catalogeller metaarkiv som funktionen finns i.

Syntax

DROP [ TEMPORARY ] FUNCTION [ IF EXISTS ] function_name

Parameters

  • function_name

    Namnet på en befintlig funktion. Funktionsnamnet kan valfritt kvalificeras med ett schema-namn.

  • TEMPORÄR

    Används för att ta bort en TEMPORARY funktion.

  • OM FINNS

    Om det anges utlöses inget undantag när funktionen inte finns.

Exempel

-- 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;