Vikas Rajput
Vikas Rajput

@vikasrajputin

11 تغريدة 4 قراءة Jul 20, 2022
SQL: What are Functions?
a thread...
(Part: 1)
1. Definition:
Functions optionally take arguments, performs some calculations or operations and returns the computed value.
Functions always return some value.
2. Types of Functions
Mainly there are two categories of functions:
- In-built/System Functions
- User Defined Functions
3. In-built Functions
Several types of built-in functions exist in DB like Aggregate functions, Date functions, String functions, etc.
Let's see some built-in functions
3.a. Aggregate Functions
Aggregate Functions work on the collection of data and return a single scalar value in return.
Eg:
MAX(<column>) - takes all column values and returns the maximum value.
SUM(<column>) - takes all column values and returns the sum of them.
3.b. String Functions
They take input as String, perform some operations and return back the modified String.
Eg:
UPPER(<str>): Takes the string as an argument, and returns the upper case string.
REVERSE(<str>): Returns the reversed string
Similarly, there are tones of other in-built functions that can be found in DB.
Depending on the database you're using, their names might differ.
Above in-built functions are based on MySQL DB.
4. User-Defined Functions
Sometimes, when in-built functions are not enough then we need to create our own customized functions.
Such types of functions are called User-Defined Functions.
We will see them in more detail in part 2 of this thread.
That's it for now!
If you liked this then you might also like my previous series on Store Procedures:
Namaste, I'm Vikas!
Every Mon, Wed & Fri - I write a thread
on Fullstack Development.
Follow @vikasrajputin to read all my future threads.
Here's the Part 2:

جاري تحميل الاقتراحات...