Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3953664
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T02:00:08+00:00 2026-05-20T02:00:08+00:00

In MySQL you can insert multiple rows like this: INSERT INTO ‘tablename’ (‘column1’, ‘column2’)

  • 0

In MySQL you can insert multiple rows like this:

INSERT INTO 'tablename' ('column1', 'column2') VALUES
    ('data1', 'data2'),
    ('data1', 'data2'),
    ('data1', 'data2'),
    ('data1', 'data2');

However, I am getting an error when I try to do something like this. Is it possible to insert multiple rows at a time in an SQLite database? What is the syntax to do that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T02:00:09+00:00Added an answer on May 20, 2026 at 2:00 am

    update

    As BrianCampbell points out here, SQLite 3.7.11 and above now supports the simpler syntax of the original post. However, the approach shown is still appropriate if you want maximum compatibility across legacy databases.

    original answer

    If I had privileges, I would bump river’s reply: You can insert multiple rows in SQLite, you just need different syntax. To make it perfectly clear, the OPs MySQL example:

    INSERT INTO 'tablename' ('column1', 'column2') VALUES
      ('data1', 'data2'),
      ('data1', 'data2'),
      ('data1', 'data2'),
      ('data1', 'data2');
    

    This can be recast into SQLite as:

         INSERT INTO 'tablename'
              SELECT 'data1' AS 'column1', 'data2' AS 'column2'
    UNION ALL SELECT 'data1', 'data2'
    UNION ALL SELECT 'data1', 'data2'
    UNION ALL SELECT 'data1', 'data2'
    

    a note on performance

    I originally used this technique to efficiently load large datasets from Ruby on Rails. However, as Jaime Cook points out, it’s not clear this is any faster wrapping individual INSERTs within a single transaction:

    BEGIN TRANSACTION;
    INSERT INTO 'tablename' table VALUES ('data1', 'data2');
    INSERT INTO 'tablename' table VALUES ('data3', 'data4');
    ...
    COMMIT;
    

    If efficiency is your goal, you should try this first.

    a note on UNION vs UNION ALL

    As several people commented, if you use UNION ALL (as shown above), all rows will be inserted, so in this case, you’d get four rows of data1, data2. If you omit the ALL, then duplicate rows will be eliminated (and the operation will presumably be a bit slower). We’re using UNION ALL since it more closely matches the semantics of the original post.

    in closing

    P.S.: Please +1 river’s reply, as it presented the solution first.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was wondering how you can insert multiple rows into a MySQL database using
I am currently using this type of SQL on MySQL to insert multiple rows
In mysql, you can insert multiple rows to a table in one query for
I know that you can insert multiple rows at once, is there a way
I know that with mysql you can write SQL statements into a .sql file
Date and time in MySQL can be stored as DATETIME, TIMESTAMP, and INTEGER (number
Can MySql 5.0 views use tables that are located on another server? What is
How cheap can MySQL be compared to MS SQL when you have tons of
When running command-line queries in MySQL you can optionally use ' \G ' as
I have a fairly good feel for what MySQL replication can do. I'm wondering

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.