Database Reference
In-Depth Information
11
Using Data Manipulation
Functions
In this chapter, you learn what functions are, what types of functions MariaDB sup-
ports, and how to use these functions.
Understanding Functions
Like almost any other computer language, SQL supports the use of functions
to manipulate data. Functions are operations usually performed on data, usually
to facilitate conversion and manipulation.
An example of a function is the RTrim() that we used in the last chapter to
trim any spaces from the end of a string.
Note
Functions Are Less Portable Than SQL Code that runs on multiple systems is said to
be portable . Most SQL statements are relatively portable, and when differences between
SQL implementations do occur they are usually not that difficult to deal with. Functions,
on the other hand, tend to be far less portable. Just about every major DBMS supports
functions that others don't, and sometimes the differences are significant.
With code portability in mind, many SQL programmers opt not to use any implementa-
tion-specific features. Although this is a somewhat noble and idealistic view, it is not
always in the best interests of application performance. If you opt not to use these
functions, you make your application code work harder. It must use other methods to do
what the DBMS could have done more efficiently.
If you do decide to use functions, make sure you comment your code well, so that at a
later date you (or another developer) will know exactly to which SQL implementation you
were writing. Code commenting was introduced back in Chapter 4, “Retrieving Data.”
 
 
 
Search WWH ::




Custom Search