Data Table imported from Excel to MySQL database

Source: Internet
Author: User
Tags mysql query mysql command line

Data Table imported from Excel to MySQL database

I simply sorted it out:

Import Excel Data to MySQL database:
1: select the data block to be imported. (Some people say there is an extra column. I don't need to do that after the test. I have exported the entire file)

2: copy the selected data block to a new table, and then "Save as"-"" text file (Tab Division) (*. txt) ". The storage path is optional.

3: Create a MySQL database and table based on the data block to be imported, and then use the command (Note: MySQL command line client) to log on, enter mysql> load data infile

'F: // workspace // Birt // PEMS. Report // SQL // data.txt'
Table warning
(Fields terminated by '/t ');

Note: Do not use tab-separated brackets by default. Do not forget the last semicolon (;). The path must be single or single quotation marks. The syntax is based on MySQL syntax to import data.
You can also run this statement in MySQL query Brower.

Now all the data has been imported into mysql. Let's take a look at the SELECT statement,
At this point, the problem of data import from Excel Data to MySQL database tables has been solved.

By the way, the process of exporting data from a data table in the MySQL database to an Excel file is the opposite. In fact, the process still relies on the TXT text file of the "Data Separator.
Similarly, enter mysql> select * into OUTFILE 'f: // workspace // Birt // PEMS. report // SQL // data.txt 'from warning; in this way, all data in warning is exported to the TXT text file. Most

The next step is to import the text file to excel.
You can open the Excel file, select "data"> "Import external data"> "import data", select the exported text file, and press OK.

Note: If you specify a specific data separator when exporting text, you will have an interface for selecting the separator when importing data in Excel.

If you want to export a specific part of data, you need to add conditions to your Export Statement. The code is similar to the following:
Select * into OUTFILE 'f: // workspace // Birt // PEMS. Report // SQL // data.txt 'from warning where columnname = 'test ';

In fact, the key here is the SQL statement. For more information, see MySQL help and related documents.

Good luck at the end ~~

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.