"MySQL" Imports an Excel table into one of MySQL's tables

Source: Internet
Author: User
Tags mysql command line

Suppose the table has a (integer field), B (integer field), C (string data) Three columns of data, you want to import into the MySQL database in the table table,table the fields that need to be inserted are COL1,COL2,COL3

1. In any column, assuming in column D, enter: =concatenate ("INSERT into table (COL1,COL2,COL3) VALUES (", A2, ",", B2, ", '", C2, "');"), because A1,B1, C1 in Excel store the header well, the data is starting from the second line, and then pull the sum, the average formula to drop down the complete table,


2, press CTRL + C, directly copy this column to Notepad paste, get a lot of insert statement.

3, open the MySQL command line Client, is the MySQL comes with an operation interface, Instead of using MySQLQueryBrowser.exe graphical interface, because some of the lower version of the MySQLQueryBrowser.exe input SQL statement containing Chinese words will be garbled.

4, enter the password, login, and then enter the "use you want to manipulate the name of the database;" By pressing ENTER, the semicolon cannot be saved, because in MySQL Command line client, a semicolon is used to distinguish a single statement.

5, input "Set names your database code;", generally GBK or utf8,gb2312 also have, pay attention to Utf-8 code here to be expressed as UTF8, without this sentence, insert Chinese or will error.

6, copy Notepad that a lot of INSERT statements, right-click on the command line, paste, cannot use Ctrl + V, wait for a little bit of MySQL execution process, then import Excel to MySQL complete

Such a method can also be used with other SQL statements and database

"MySQL" Imports an Excel table into one of MySQL's tables

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.