100 records are inserted cyclically using stored procedures, and 100 records are stored.

Source: Internet
Author: User

100 records are inserted cyclically using stored procedures, and 100 records are stored.

Mysql> delimiter $ mysql> create procedure p3 ()-> modifies SQL data-> BEGIN-> set @ I = 0;-> set @ max = 100; -> while @ I <@ max do-> insert into user values (@ I);-> set @ I = @ I + 1;-> end while; -> end $

How can 100 records be inserted cyclically in the SQL database? Is stored procedure required?

Declare @ a as int
Set @ a = 1
While (@ a <= 100)
Insert into table1 values ('','','','')
Set @ a = @ a + 1
If @ a> 100

How to extract the first N records or insert N records using the stored procedure?

It is better to extract the first N records and pass N as a parameter to the stored procedure,
You can retrieve the first N pieces of data by sorting the top keywords.
To insert N records, you must first import the data into the stored procedure and use continuous insertion.

Related Article

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.