如何向sql数据库添加大量数据?

时间:2021-09-25 15:33:15

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

我目前正在尝试将1k记录插入到sql数据库中,但尚未找到快速解决方案。从下面我可以看到,我有三列数据,我想将它们插入下面屏幕截图的三列。如果有人可以帮助我或建议任何时候我真的很感激帮助。 - 我使用过CSV Inport,工作过: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

如何向sql数据库添加大量数据?

1 个解决方案

#1


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.

当你执行数据库的mysqldump时,MySQL就是这样做的。

#1


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.

当你执行数据库的mysqldump时,MySQL就是这样做的。