In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
MySQL pretreatment technology is what, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, I hope you can gain something.
Traditional mysql processing flow
1. Prepare sql statements on the client side
2. Send sql statements to the MySQL server
3, execute the sql statement on the MySQL server
4, the server returns the execution result to the client
In this way, each sql statement is requested once, and the mysql server will receive and process it once. When a script file is executed repeatedly for the same statement, the pressure on the mysql server will increase, so there is mysql preprocessing to reduce the pressure on the server!
Basic strategies for preprocessing:
Force the sql statement into two:
The first part is the same command and structure as before.
The second part is the later variable data part.
When executing the sql statement, first send the same command and structure part to the MySQL server, let the MySQL server do a preprocessing in advance (at this time there is no real execution of the sql statement), and in order to ensure the structural integrity of the sql statement, the variable data parts are represented by a data placeholder when sending the sql statement for the first time! Like a question mark? Is a common data placeholder!
There are two forms of MySQL preprocessing: preprocessing with or without parameters
1. Preprocessing without parameters
First take a look at the data in the table!
1. Prepare the preprocessing statement
Prepare statement name from "preprocessed sql statement"
Prepare sql_1 from "select * from pdo"
2. Execute the preprocessing statement
Execute statement name
Execute sql_1
3. Delete preprocessing
Drop prepare statement name
Drop prepare sql_1
After deletion, the preprocessing statement can no longer be executed!
Second, pretreatment with parameters
1. Prepare the preprocessing statement
Prepare statement name from "preprocessed sql statement"
Prepare sql_2 from "select * from pdo where id =?"
2. Define parameter variables
Set @ variable name = value;-- where @ is a grammatical form for defining variables in MySQL (analogous to the $symbol in php)
Set @ id=2
3. Pass parameter variables and execute preprocessing statements
Execute statement name using parameter variable
Execute sql_2 using @ id;-- choose the message for id=2
4. Delete preprocessing
Drop prepare statement name
Drop prepare sql_2
Note: if there is more than one data placeholder, just pass the parameters in the order of the data placeholder:
Prepare sql_2 from "select * from pdo where id >? & & age >?"
Set @ id=2
Set @ age=30
Execute sql_2 using @ id,@age
Note that the unknown parameters here should correspond to the placeholders in step 1
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.