从 CSV 导入 MySql
我有一个包含三列的表,NODEID、X、Y。NODEID 是主键,它被设置为 INT(4) 以进行自动增量。我希望通过 phpmyadmin 导入从 CSV 导入更多数据到此表中。问题:
- CSV 的格式是什么样的?
- 这可能吗?或者导入基本上只是为了用 CSV 替换整个数据?
截至目前,CSV 看起来像:
1,-105.057578,39.785603
2,-105.038646,39.771132
3,-105.013045,39.771727
5,-105.045721,39.762055
6,-105.031777,39.76206
7,-105.046015,39.72835
8,-105.029796,39.728304
10,-104.930863,39.754579
11,-104.910624,39.754644
13,-104.930959,39.74367
16,-105.045802,39.685253
17,-105.032149,39.688557
18,-105.060891,39.657622
20,-105.042257,39.644086
等等...
I have a table with three columns, NODEID, X, Y. NODEID is the primary key and it is set as an INT(4) to be AUTOINCREMENT. I wish to add more data to this table by importing it from a CSV via the phpmyadmin import. Question:
- What would be the format of the CSV look like?
- Is this possible or is importing basically just to replace the whole data with the CSV?
As of now the CSV looks like:
1,-105.057578,39.785603
2,-105.038646,39.771132
3,-105.013045,39.771727
5,-105.045721,39.762055
6,-105.031777,39.76206
7,-105.046015,39.72835
8,-105.029796,39.728304
10,-104.930863,39.754579
11,-104.910624,39.754644
13,-104.930959,39.74367
16,-105.045802,39.685253
17,-105.032149,39.688557
18,-105.060891,39.657622
20,-105.042257,39.644086
etc...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将 phpmyadmin 将运行的 SQL 更改为:(
您只需更改最后一行)
你的csv应该看起来像
最后一行告诉MySQL只查找这两列数据并为任何其他列插入null。 NULL 值将按预期自动递增。
Change the SQL that phpmyadmin will run to this:
(You will only have to change the last line)
And your csv should look like
The last line tells MySQL to look for only those two columns of data and insert null for any other columns. The NULL value will be auto-incremented as expected.