Home  >  Article  >  Database  >  What is the method to add data in batches using sql statements?

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

hzc
hzcOriginal
2020-06-22 16:45:1411437browse

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');

Method 2: Batch execution, suitable for SQL Server.

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

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;

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!

Statement:
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