The DROP FUNCTION
statement enables you to delete a user-defined function.
Syntax
drop-function ::= DROP FUNCTION name
- name
-
The name of the function. This is usually an unqualified identifier, such as
func1
or`func-1`
. In this case, the path to the function is determined by the current query context.To delete a global function in a particular namespace, the function name must be a qualified identifier with a namespace, such as
default:func1
. Similarly, to delete a scope function in a particular scope, the function name must be a qualified identifier with the full path to a scope, such asdefault:`travel-sample`.inventory.func1
. Refer to Global Functions and Scope Functions for more information.
The name of a user-defined function is case-sensitive, unlike that of a built-in function. You must delete the user-defined function using the same case that was used when it was created. |
Usage
When you drop an external user-defined function, the JavaScript library and function on which the user-defined function depended are not deleted. This enables you to create a new user-defined function with a different name, or a different number of parameters, using the same JavaScript library and function.
To change or delete the JavaScript library and the JavaScript function, you must use the N1QL Functions REST API. For details, refer to Functions REST API.
Examples
This statement deletes an inline function called celsius
.
DROP FUNCTION celsius;
You can run the following query to check that the function is no longer available.
SELECT * FROM system:functions;
These statements delete two external functions:
-
A function called
geohash
, which depends on the JavaScriptencodeGeoHash
function in thegeohash-js
library; -
A function called
adjacent
, which depends on the JavaScriptcalculateAdjacent
function in thegeohash-js
library.
DROP FUNCTION geohash;
DROP FUNCTION adjacent;
You can run the following command to check that the JavaScript geohash-js
library and the encodeGeoHash
and calculateAdjacent
functions are still available.
curl -v -X GET \
http://localhost:8093/evaluator/v1/libraries/geohash-js \
-u Administrator:password
Related Links
-
To create user-defined functions, refer to CREATE FUNCTION.
-
To execute user-defined functions, refer to EXECUTE FUNCTION.
-
To include user-defined functions in an expression, refer to User-Defined Functions.
-
To view user-defined functions, refer to Monitor Queries.