mysql quickly adds statements with millions of records

  • 2020-06-03 08:34:22
  • OfStack

The following principles must be followed when inserting records using the Insert Select statement.
When selecting data with the Select statement, you cannot select rows from the table in which the data is inserted.
Specify that the number of fields included after the inserted table must be the same as the number of fields returned in the Select statement.
Specifies that the inserted table must contain the same field data type as the one returned in the Select statement or that the system can automatically convert.

INSERT INTO ler_items( classid, title, address, zipcode )
SELECT classid, title, address, zipcode
FROM ler_items 

Using the SQL statement above, you can add millions of records to the ler_items table in a very short time, which is helpful for database testing

Related articles: