共用方式為


DROP 函式

適用於: 檢查標示為是 Databricks SQL 檢查標示為是 Databricks Runtime

卸除暫時或永久的使用者定義函式 (UDF)。 若要卸除函式,您必須是函式的擁有者,或函式所在的架構、目錄或中繼存放區擁有者。

語法

DROP [ TEMPORARY ] FUNCTION [ IF EXISTS ] function_name

參數

  • function_name

    現有函式的名稱。 函式名稱可能選擇性地以架構名稱限定。

  • TEMPORARY

    用來刪除函 TEMPORARY 式。

  • IF EXISTS

    如果指定,當函式不存在時,不會擲回任何例外狀況。

範例

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