Home > Database > Mysql Tutorial > body text

How to upload data into multiple MySQL tables using mysqlimport?

王林
Release: 2023-09-07 15:57:05
forward
839 people have browsed it

How to upload data into multiple MySQL tables using mysqlimport?

With the help of mysqlimport, we can upload data to multiple MySQL tables. Instructions are provided in the example below:

Example

Suppose we want to upload the following data from two data files student1_tbl.txt:

1     Saurav     11th
2     Sahil      11th
3     Digvijay   11th
Copy after login

Also There is House.txt

1   Furniture
2   Television
3   Refrigerator
Copy after login

The following are the MySQL tables to which we want to upload the above data-

mysql> DESCRIBE Student1_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)

mysql> DESCRIBE House;
+-------+-------------+------+-----+---------+-------+
| Field | Type        | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| Sr    | int(11)     | YES  |     | NULL    |       |
| Name  | varchar(20) | YES  |     | NULL    |       |
+-------+-------------+------+-----+---------+-------+
2 rows in set (0.00 sec)
Copy after login

Now with the help of the following commands we can upload the data into these two tables-

C:\mysql\bin>mysqlimport -u root query C:/mysql/bin/mysql-files/student_tbl.txt C:/mysql/bin/mysql-files/house.txt
query.student_tbl: Records: 3 Deleted: 0 Skipped: 0 Warnings: 0
query.house: Records: 3 Deleted: 0 Skipped: 0 Warnings: 0

mysql> Select * from House;
+------+--------------+
| Sr   | Name         |
+------+--------------+
| 1    | Furniture    |
| 2    | Televisoin   |
| 3    | Refrigerator |
+------+--------------+
3 rows in set (0.00 sec)

mysql> Select * from student1_tbl;
+--------+----------+-------+
| RollNo | Name     | Class |
+--------+----------+-------+
| 1      | Saurav   | 11th |
| 2      | Sahil    | 11th |
| 3      | Digvijay | 11th |
+--------+----------+-------+
3 rows in set (0.00 sec)
Copy after login

The above is the detailed content of How to upload data into multiple MySQL tables using mysqlimport?. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template