# Create a Function

In 
Published 2022-12-03

This tutorial explains to you how to create a function into MySQL database (schema).

In MySQL, a schema is synonymous with a database. You can substitute the keyword SCHEMA instead of DATABASE in MySQL SQL syntax, for example using CREATE SCHEMA instead of CREATE DATABASE.

When you create a function into a MySQL schema, you can consider that you create a function into a specific database.

In my case I will create a function into the "x" database (schema).

If you want to create the function using the MySQL Workbench, here are the steps.

Connect to the MySQL Workbench, and right click on the schema/function where you want to create that function :

Choose the "Crete Function ..." and you will see the following screen:

Enter the code for creating the function:

Click on "Apply" and you will see the following screen:

DEFINER = who create the view

Click on "Apply" and you will see the following screen:

Now the function is created, and you can call that function later.

You can call that function into a SELECT as well:

select `x`.`function1`();