DROP 函式
適用于: Databricks SQL Databricks Runtime
(UDF) 卸載暫時或永久的使用者定義函式。 若要卸載函式,您必須是其擁有者,或函式所在的架構、目錄或中繼存放區擁有者。
語法
DROP [ TEMPORARY ] FUNCTION [ IF EXISTS ] function_name
參數
-
現有函式的名稱。 函式名稱可能選擇性地以架構名稱限定。
臨時
用來刪除函
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;