
- 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 transfer information between MySQL and data files?
Transferring the information between MySQL and data files mean importing data from data files into our database or exporting data from our database into files. MySQL is having two statements that can be used to import or export data between MySQL and data files −
LOAD DATA INFILE
This statement is used for importing the data from data files into our database. It reads data records directly from a file and inserts them into a table. Its syntax would be as follows −
Syntax
LOAD DATA LOCAL INFILE '[path/][file_name]' INTO TABLE [table_name ];
Here, the path is the address of the file.
file_name is the name of the .txt file
table_name is the table where the data will be loaded.
SELECT … INTO OUTFILE
This statement is used for exporting the data from our database into data files. This statement writes the result of a SELECT operation to a file. Its syntax would be as follows −
Syntax
SELECT … INTO OUTFILE '[path/][file_name]' FROM TABLE [table_name ];
Here, the path is the address of the file.
file_name is the name of the .txt file
table_name is the table from where the data, after SELECT statement, would be selected.
Both the above-described statements are similar in the sense that they are related to the transfer of data either from the data file to database or from the database to a data file.
- Related Articles
- How can we transfer information between MySQL and data files through command line?
- Transfer Files Between Linux Machines Over SSH
- Difference Between Data and Information
- How can we import CSV files into MySQL tables by using mysqlimport?
- How can we distinguish between MySQL IFNULL() and NULLIF() functions?
- How can we insert data into a MySQL table?
- How can we compare data in two MySQL tables?
- How we can compress large Python files?
- How can we distinguish between MySQL CROSS JOIN and INNER JOIN?
- 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 upload data into MySQL tables by using mysqlimport?
- How can we filter data with the help of MySQL subquery?
- How we can split Python class into multiple files?
- How can I transfer data from SAP HANA to virtual table?
