When logging in to the stress test, many different users are required, and new data needs to be added to the database #Batch add user accounts - stored procedure: delimiter // drop procedure if exists test; create procedure test() begin DECLARE i int; set i = 1; while i<21 do insert into hg_user values (concat("OM_TEST",cast(i as CHAR)),concat("OM_TEST",cast(i as CHAR)),"F1B2F5B9FBC8B513",null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null); set i = i+1; end while; select * from test; end// call test(); delimiter is the MySQL delimiter. The default delimiter in the MySQL client is a semicolon (;). If you input more statements at one time and there is a semicolon in the middle of the statement, you need to specify a special separator, commonly used ones are // and &&. The above is, first set the separator to //, The statement is not executed as a whole until the next // is encountered. After execution, the last line, delimiter; resets the MySQL delimiter to a semicolon. If not modified, all separators in this session will be based on //. concat is a character concatenation, which connects multiple strings into one string. Syntax: concat(str1, str2,...)
The cast function is used to explicitly convert an expression of one data type to another data type. Syntax: CAST (expression AS data_type) There are restrictions on the types that can be converted. The type can be one of the following values:
Batch deletion solution (the same applies to deleting users) #Delete solution - stored procedure; delimiter // drop procedure if exists test; create procedure test() begin DECLARE i int; set i = 1; while i<11 do DELETE from hg_application_flow_template where user_name=concat("OM_TEST",cast(i as CHAR)); DELETE from hg_application_flow_template_details where created_by=concat("OM_TEST",cast(i as CHAR)); set i = i+1; end while; select * from test; end// call test(); Summarize This is the end of this article about MySQL batch addition and storage. For more relevant MySQL batch addition and storage content, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: How to hide the border/separation line between cells in a table
>>: Vue complete code to implement single sign-on control
Achieve resultsImplementation Code html <heade...
In this article, we sorted out the startup proces...
1. Introduction to keepalived Keepalived was orig...
In this article, we’ll explore how async/await is...
Let's talk about the difference first last, t...
Nginx: PV, UV, independent IP Everyone who makes ...
Table of contents 1. Introduction 2. Prepare a pr...
Use canvas to create graphics and text with shado...
Since I have parsed HTML before, I want to use Vu...
1. Introduction to nmon Nmon (Nigel's Monitor...
First, we need a server with Docker installed. (I...
Table of contents 1. Implement the component time...
Table of contents 1. Custom instructions 1. Regis...
First, what is box collapse? Elements that should...
Table of contents background Compile glibc 2.14 M...