Home > Database > SQL > body text

What is the method to add data in batches using sql statements?

hzc
Release: 2020-06-22 16:45:14
Original
11444 people have browsed it

What is the method to add data in batches using sql statements?

#What is the method for adding data in batches using sql statements?

Method 1: Execute one by one, slow .

INSERT INTO testimport (name, message)VALUES ('testname', 'jfksdfkdsfjksadljfkdsfjsdlafjdaslkfjasfd');
INSERT INTO testimport (name, message)VALUES ('testname', 'jfksdfkdsfjksadljfkdsfjsdlafjdaslkfjasfd');
INSERT INTO testimport (name, message)VALUES ('testname', 'jfksdfkdsfjksadljfkdsfjsdlafjdaslkfjasfd');
Copy after login

Method 2: Batch execution, suitable for SQL Server.

INSERT INTO testimport (name, message)  VALUES
('testname', 'jfksdfkdsfjksadljfkdsfjsdlafjdaslkfjasfd'),
('testname', 'jfksdfkdsfjksadljfkdsfjsdlafjdaslkfjasfd'),
('testname', 'jfksdfkdsfjksadljfkdsfjsdlafjdaslkfjasfd');
Copy after login

Method 3: Batch execution, suitable for Oracle.

INSERT ALL 
    INTO A (name, message) VALUES ('testname', 'jfksdfkdsfjksadljfkdsfjsdlafjdaslkfjasfd')    
    INTO A (name, message) VALUES ('testname', 'jfksdfkdsfjksadljfkdsfjsdlafjdaslkfjasfd')    
    INTO A (name, message) VALUES ('testname', 'jfksdfkdsfjksadljfkdsfjsdlafjdaslkfjasfd')
SELECT 1
FROM DUAL;
Copy after login

Recommended tutorial: "sql tutorial"

The above is the detailed content of What is the method to add data in batches using sql statements?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
sql
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template