2

I'm currently trying to insert 1k records into a sql database and haven't yet found a quick solution yet. As you can see from the below I have three columns of data and I'm wanting to insert them into the three columns on the screenshot below. If anyone could help me out or suggest any times I'd really apprecate the help. - I've used CSV Inport, Worked a treat :D

usernames   password    activation
    100001  ad3cd3c1    ad3cd3c1
    100002  a233b444    a233b444
    100003  dcdcbb12    dcdcbb12
    100004  4c1a1bd1    4c1a1bd1
    100005  dc13341a    dc13341a
    100006  2dda12ba    2dda12ba
    100007  42b3cac4    42b3cac4
    100008  cb2bd4bd    cb2bd4bd
    100009  b4cd4333    b4cd4333
    100010  adbcca13    adbcca13
    100011  23ddc211    23ddc211
    100012  11224aa2    11224aa2

Database Snap Shot

Delete
  • 429
  • 1
  • 6
  • 25

1 Answers1

2

From a personal experience where I had to insert millions of records in a table, the quickest way (that suited my case) was to create a single insert statement like so:

INSERT INTO Members(Username, password, activation)
    VALUES('100001', 'ad3cd3c1', 'ad3cd3c1')
    ,('100001', 'ad3cd3c1', 'ad3cd3c1')
    ,('100001', 'ad3cd3c1', 'ad3cd3c1') ...;

That's how MySQL does it when you do mysqldump of your database.

Tamim Al Manaseer
  • 3,554
  • 3
  • 24
  • 33
  • To turn your data (as you presented it in your question) to such a query, you can write a script, or use a text editor that allows you to have multiple cursors (e.g. Sublime Text 2). – Pelle Jul 16 '13 at 09:56