您好,欢迎访问一九零五行业门户网

如何使用mysqlimport将数据上传到MySQL表中?

for uploading the data into mysql tables by using mysqlimport we need to follow following steps −
step-1 − creating the table
first of all, we need to have a table in which we want to upload the data. we can use create table statement for creating a mysql table. for example, we created a table named ‘student_tbl’ as follows −
mysql> describe student_tbl;+--------+-------------+------+-----+---------+-------+| field | type | null | key | default | extra |+--------+-------------+------+-----+---------+-------+| rollno | int(11) | yes | | null | || name | varchar(20) | yes | | null | || class | varchar(20) | yes | | null | |+--------+-------------+------+-----+---------+-------+3 rows in set (0.06 sec)
step-2 − 创建数据文件
现在,在这一步中,我们需要创建一个数据文件,其中包含以制表符分隔的字段。由于我们知道数据文件的名称必须与mysql表的名称相同,因此我们将创建名为“student_tbl.txt”的数据文件,其中包含以下数据:
1 gaurav 10th2 rahul 10th3 digvijay 10th
step-3 − 上传数据
现在通过使用mysqlimport命令,我们可以导入这个文件 −
c:\mysql\bin>mysqlimport -u root query c:/mysql/bin/mysql-files/student_tbl.txtquery.student_tbl: records: 3 deleted: 0 skipped: 0 warnings: 0
现在通过以下查询的帮助,我们可以看到数据已经上传到表中 −
mysql> select * from student_tbl;+--------+----------+-------+| rollno | name | class |+--------+----------+-------+| 1 | gaurav | 10th || 2 | rahul | 10th || 3 | digvijay | 10th |+--------+----------+-------+3 rows in set (0.00 sec)
以上就是如何使用mysqlimport将数据上传到mysql表中?的详细内容。
其它类似信息

推荐信息