我正在将一些 20000 行的数据从 CSV 文件导入 Mysql.
I am importing some data of 20000 rows from a CSV file into Mysql.
CSV 中的列与 MySQL 表的列的顺序不同.如何自动分配Mysql表列对应的列?
Columns in the CSV are in a different order than MySQL table's columns. How to automatically assign columns corresponding to Mysql table columns?
当我执行
LOAD DATA INFILE'abc.csv' INTO TABLE abc
此查询将所有数据添加到第一列.
this query adds all data to the first column.
请建议将数据导入 Mysql 的自动语法.
Please suggest auto syntax for importing data to Mysql.
您可以使用 LOAD DATA INFILE 命令将 csv 文件导入表中.
You can use LOAD DATA INFILE command to import csv file into table.
检查这个链接MySQL - LOAD DATA INFILE.
Check this link MySQL - LOAD DATA INFILE.
LOAD DATA LOCAL INFILE 'abc.csv' INTO TABLE abc
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\r\n'
IGNORE 1 LINES
(col1, col2, col3, col4, col5...);
对于 MySQL 8.0 用户:
使用 LOCAL 关键字会带来安全风险,从 MySQL 8.0 开始,LOCAL 功能默认设置为 False.您可能会看到错误:
Using the LOCAL keyword hold security risks and as of MySQL 8.0 the LOCAL capability is set to False by default. You might see the error:
ERROR 1148: 此 MySQL 版本不允许使用的命令
ERROR 1148: The used command is not allowed with this MySQL version
您可以按照中的说明覆盖它文档.请注意,这种覆盖并不能解决安全问题,而只是承认您知道并愿意承担风险.
You can overwrite it by following the instructions in the docs. Beware that such overwrite does not solve the security issue but rather just an acknowledge that you are aware and willing to take the risk.
这篇关于MYSQL 使用 LOAD DATA INFILE 从 csv 导入数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
如何有效地使用窗口函数根据 N 个先前值来决定How to use windowing functions efficiently to decide next N number of rows based on N number of previous values(如何有效地使用窗口函数根据
在“GROUP BY"中重用选择表达式的结果;条款reuse the result of a select expression in the quot;GROUP BYquot; clause?(在“GROUP BY中重用选择表达式的结果;条款?)
Pyspark DataFrameWriter jdbc 函数的 ignore 选项是忽略整Does ignore option of Pyspark DataFrameWriter jdbc function ignore entire transaction or just offending rows?(Pyspark DataFrameWriter jdbc 函数的 ig
使用 INSERT INTO table ON DUPLICATE KEY 时出错,使用 Error while using INSERT INTO table ON DUPLICATE KEY, using a for loop array(使用 INSERT INTO table ON DUPLICATE KEY 时出错,使用 for 循环数组
pyspark mysql jdbc load 调用 o23.load 时发生错误 没有合pyspark mysql jdbc load An error occurred while calling o23.load No suitable driver(pyspark mysql jdbc load 调用 o23.load 时发生错误 没有合适的
如何将 Apache Spark 与 MySQL 集成以将数据库表作为How to integrate Apache Spark with MySQL for reading database tables as a spark dataframe?(如何将 Apache Spark 与 MySQL 集成以将数据库表作为