
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
How can we upload data into multiple MySQL tables by using mysqlimport?
With the help of mysqlimport we can upload data into multiple MySQL tables. It is illustrated in the example below −
Example
Suppose we want to upload the following data from two data files namely student1_tbl.txt −
1 Saurav 11th 2 Sahil 11th 3 Digvijay 11th
And House.txt
1 Furniture 2 Television 3 Refrigerator
Followings are MySQL tables into 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)
Now, with the help of the following command 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)
- Related Articles
- How can we upload data into MySQL tables by using mysqlimport?
- How can we import CSV files into MySQL tables by using mysqlimport?
- How can we create a MySQL view by using data from multiple tables?
- How can we compare data in two MySQL tables?
- How can we insert data into an existing MySQL table by using PHP script?
- How can we insert data into a MySQL table?
- mysqlimport - A MySQL Data Import Program
- How can we import data from .txt file into MySQL table?
- How can we import data from .CSV file into MySQL table?
- How can we set up a MySQL User account by using INSERT INTO statement?
- How can I sum columns across multiple tables in MySQL?
- How can we see MySQL temporary tables in the list of tables?
- How can we MySQL LOAD DATA INFILE statement with ‘ENCLOSED BY’ option to import data from text file into MySQL table?
- How can we access tables through MySQL stored procedures?
- Why can't we upload multiple files anymore at Coding Ground?

Advertisements