<a id="flink-sql-create-function"></a>

# CREATE FUNCTION Statement

Confluent Cloud for Apache Flink® enables registering custom user-defined functions (UDFs) by
using the CREATE FUNCTION statement. After you register your UDFs in a
Flink database, you can use them in your SQL queries.

## Syntax

```sql
CREATE FUNCTION <function_name>
  AS <class_name>
  USING JAR 'confluent-artifact://<artifact_id>'
  [USING CONNECTIONS ('<connection_name>' [, ...])];
```

## Description

Register a user-defined function (UDF) in the current database.

The optional `USING CONNECTIONS` clause binds one or more
[connection objects](../../../integrations/connections/overview.md#connections-overview) to the UDF, enabling
[external connectivity](../../concepts/user-defined-functions.md#flink-sql-udfs-external-connectivity) so the
function can call external systems at runtime. Provide one or more
connection names, separated by commas. The connection name must match the
prefix that the UDF uses with `FunctionContext.getJobParameter()`. For
example, use `USING CONNECTIONS ('my_external_service')` for a
`my_external_service.endpoint` parameter.

- To remove a UDF from the current database, use
  [DROP FUNCTION](drop-function.md#flink-sql-drop-function).
- To view the UDFs in the current database, use
  [SHOW FUNCTIONS](show.md#flink-sql-show-functions).

#### NOTE
UDFs are immutable. Flink has no `ALTER FUNCTION` or `CREATE OR REPLACE
FUNCTION` statement, so to update a UDF, drop it and create a new
function that points to the updated artifact. Dropping a function that other
statements depend on can break the other statements. To ensure your
statements work, see [Update a UDF safely](../../how-to-guides/create-udf.md#flink-sql-update-udf).

## Related content

- [Create a User-Defined Function](../../how-to-guides/create-udf.md#flink-sql-create-udf)
- [Update a UDF safely](../../how-to-guides/create-udf.md#flink-sql-update-udf)
- [DROP FUNCTION](drop-function.md#flink-sql-drop-function)
- [SHOW FUNCTIONS](show.md#flink-sql-show-functions)
- [confluent flink artifact create](https://docs.confluent.io/confluent-cli/current/command-reference/flink/artifact/confluent_flink_artifact_create.html)

#### NOTE
This website includes content developed at the [Apache Software Foundation](https://www.apache.org/)
under the terms of the [Apache License v2](https://www.apache.org/licenses/LICENSE-2.0.html).
