开发者

What are MySQL functions? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. 开发者_JS百科Closed 9 years ago.

I use Navicat for MySQL and I see "functions". How they are used? What are they? What is their main purpose?


In SQL functions are subprograms defined inside the database. They are basically functions that can be called from inside SQL statements, and are useful for the same reasons that calling functions in other languages are useful. Most SQL languages come with some simple important functions and user defined functions can be added. For example, MySQL contains the function count(). It can be called like so:

select count(some_column) from some_table;

This will count the number of rows that are in the some_column column of the some_table table. You will get a response something like:

*|count(some_column)
1|200

SQL functions similar to, but different from stored procedures in SQL for these reasons:

  • Functions must return a single value. Stored procedures on the other hand, may return multiple values or even no return value.
  • Functions can be placed inside select statements. Stored procedures can't.

You can find more information about functions and stored procedures here:

http://www.w3schools.com/sql/sql_functions.asp

http://en.wikipedia.org/wiki/User-defined_function

http://dev.mysql.com/doc/refman/5.0/en/functions.html

What's the point of a stored procedure?

http://en.wikipedia.org/wiki/Stored_procedure

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜