stored procedures and functionsmeaning: A set of pre-compiled SQL statements that understand batch processing statements 1 and improve the reusability of code 2 , simplified operation 3 , reducing the number of compilations and the number
Introduction to global serial numbers in 1.MyCatThe database self-increment primary key cannot guarantee the global uniqueness of the self-increment primary key in the case of implementing the Sub-Library table. To do this, MYCAT provides a global
There are always some complex logic that we need to use more than once, and it shows the importance of the function at this point.Features of the MySQL function
Name of function
Parameter list
function body
return value
1. Oracel can support sequence directly, but MySQL does not support sequence, so we will create sequence in MySQL by simulating the sequence method.Methods for simulating sequence:Project scenario:Project application, there was one of the following
SQL stored procedures:Origin: In a specific application, a complete operation will contain multiple SQL statements, which need to be executed according to the execution result of the preceding SQL statement to execute the following SQL statement. As
First, login parameters-D Open the specified database-H server name-p password-P port-u user name-V Output version information and exit--prompt prompt mysql>, or log in with prompt commandPrompt:\d Full Date\d Current Database\h Server Name\u
First, the basic statement of the Operation databasecmd into MySQL: mysql-uroot-pCreating database: Create library name;Create data Table : with SQLite;View database : Show DATABASES;View Data Sheet : show TABLES;Enter database : use library
GoalHow to create a function in the MySQL databaseGrammarCREATE FUNCTION func_name ([func_parameter])//parentheses are required, parameters are optional returns type[characteristic ...] routine_body
The CREATE function keyword used for
set names GBK;Date_format (publish_datetime, '%y-%m-%d ');Select Date_format (now (), '%y year%m month%d day%h:%i min:%s seconds ');To create a real time function:Create function F1 () returns varchar(return date_format (now (),'%y Year% M month%d
1) Create a scalar function, calculate the average score for the course with the specified course number, and then call the function to query the average score for a course. Create function My_avg (@cno char (6)) returns Realasbegindeclare @par
Tag:databases status process Database tables A. show tables or show tables from database_name; -- displays the names of all tables in the current database b. show databases; -- displays the names of all databases in MySQL
Original: MySQL stored procedures and common functionsA. function1. Mathematical FunctionsCeil () into a roundingSELECT ceil (1.2); 2Floor () Rounding and roundingSELECT floor (1.9); 9MoD take remainder (modulo)SELECT MOD (3,8); 3--3 to 8
Custom functionsUser-defined functions are a way to extend MySQL, using the same functionality as built-in functionsFunctions can return any type of value, and they can also receive parameters of these typesThe function body consists of a valid SQL
Original: http://www.cnblogs.com/zhangminghui/p/4113160.htmlIntroductionMySQL itself provides built-in functions that are very handy for our daily development and data operations, such as the aggregate function sum (), AVG () and DateTime functions
In the server development process, the general use of MySQL and other relational database as the ultimate storage engine, Redis can also be used as a key-value pairs of database, but in some real-world scenarios, especially relational structure is
A. function1. Mathematical FunctionsCeil () into a roundingSELECT ceil (1.2); 2Floor () Rounding and roundingSELECT floor (1.9); 9MoD take remainder (modulo)SELECT MOD (3,8); 3--3 to 8 moduloPower () Power operationSELECT POWER (3,2); 9ROUND ()
ares-sdk Initial development test using Oracle database, due to the special needs of Ningbo Tsusho, the database environment must be shifted from Oracle to MySQL. the problems and experiences in the conversion process are summarized as
1. Syntax1.1 New functionCreate function function_name (parameter list) returns return value type function Body(1) The function name should be a valid identifier and should not conflict with an existing keyword .(2) a function should belong to a
DB2 Date Time function(DATE (TRIM (CHAR (dt#11y)) | | -' | | TRIM (CHAR (dt#11m)) | | ' -' | | TRIM (CHAR (dt#11d))) between date (' & StrDate1 & ') and date (' & StrDate2 & '))(Y > Y) or ((y = y) and (M > m)) or ((y = y) and (M = m) and (d >=
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.