Custom functionsCreating a Custom functionCREATE FUNCTION function_nameRETURNS{STRING | Interger | REAL | DECIMAL}Routine_bodyAbout function bodies
The function body consists of a valid SQL statement
The function body can be a simple select
BEGINDECLARE Cflag bit DEFAULT 0;DECLARE CID int;DECLARE CNAME VARCHAR (16);--Declaring a cursorDeclare cur_copy CURSOR for select id,name from fruit;--Set cursor end tagDECLARE CONTINUE HANDLER for not found set cflag=1;--Open cursorOPEN cur_copy;--
Definition and usageThe Curdate () function returns the current date.GrammarCurdate ()Example 1Here is the SELECT statement:SELECT now (), Curdate (), Curtime ()The results are similar:
Now
()
curdate ()
curtime ()
1, the MySQL official website downloads the Mysql-5.5.53-winx64.msi file and saves to the disk corresponding directory.2. Graphical installation of MySQL database:1) Double click Mysql-5.5.53-winx64.msi, the Welcome screen appears, default, Next:2)
PrefaceIn the database is a sheet of inextricably linked tables, so the table design is good or bad, will directly affect the entire database. While designing the table, we will focus on one issue and what storage engine to use. Wait a minute,
@echo Off &setlocal enableextensions::----------Configuration Items----------:: Backup placement path, plus \ Set Backup_path=E:\Backup:: The name of the database to be backed up, with multiple spaces separating set DATABASES=Test:: MySQL user Name
New User:Create user username; --Create an empty password user.Create user username identified by ' password '; -Create a password when creating a new user.Grant Select[,insert ...] on Mysql.user to username identified by ' password '; --Create a
This article will focus on some of the common syntax differences between MySQL and SQL Server, as well as the related content of common stored procedures. 1. identifier qualifier SQL Server[]MYSQL "2. String addition SQL Server directly
Mysql Stored Procedure example
/*Define VariablesMethod 1: set @ variable name = value;Method 2: select value into @ variable name;Method 3: default Value of the declare variable name type (string type plus range;
The value of the in parameter will
Explain SQL efficiency and explain SQL Efficiency
The Explain command is the first recommended command for solving database performance. Most performance problems can be solved simply by using this command. The Explain command can be used to view
Mysql uses init-connect to add the implementation of the access audit function, mysqlinit-connect
Mysql is first initialized through init-connect and then connected to the instance.
We use this to record the user's thread_id, user name, and user
Mysql order by in (recommended) and mysqlorder
// MySQL statement SELECT * FROM 'mytable' WHERE 'id' IN (111, 111) order by field ('id );
Laravel framework
$ Ids = array (1, 17, 2); $ ids_ordered = implode (',', $ itemIds); $ items = static:
MySQL Cache Optimization and mysql Cache Optimization
I'm glad to have a blogger mark my article. After I know mark, I will seldom continue to pay attention to it. However, it is explained from the perspective that when a blogger opens a blog, he
Solve the problem of Chinese garbled characters in Mysql5.7 and Chinese garbled characters in mysql5.7
When using mysql5.7, you will find garbled characters appear after you write Chinese characters to the database through the web end. However,
Backup and restoration of a single mysql table and a single mysql table
A. Install MySQL backup tool xtrabackup
1. percona official xtrabackup binary version; decompress the binary version to use it.
2. Decompress xtrabackup and create a connection.
Innodb Engine redo file maintenance method, innodb Engine redo Maintenance
To adjust the size and number of redo log files of innodb, follow these steps:
1. Disable mysql
Mysqladmin-h127.0.0.1-P3306-uroot-p shutdown
2. Modify
Detailed description of MySql slow query analysis and enabling slow query log, detailed description of mysql enabling log
I am also studying MySQL performance optimization recently, so I will take a study note today!
In projects developed by our
Detailed description of mysql row-to-column and column-to-row instances, mysql instances
Mysql row-to-column and column-to-row
It is not difficult to explain the statement. When you look at the statement, explain the sentence from the inside
Mysqldump instances and mysqldump instances are excluded from database backup.
Note:
Use mysqldump-all-databases to export all databases. However, if the master node dumps data from the master database, we do not need or want information_schema or
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.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service