In MySQL, the Export and import of Excel file data

Source: Internet
Author: User

Export of data:

SELECT * FROM mytable into outfile ' D:/mytable.xls ';

You can find the Mytable.xls file under the packing directory.

Import of data:

Import with exported table Mytable.xls: Input command: Load data infile ' d:/mytable.xls ' into table mytable;

Note: mytable: is the table name of the database

When a table in the database has a primary key and a self-increment field, an error occurs, the data cannot be added, and the solution:

  1. Remove the column from the Mytable.xls table and the primary key
  2. Input command: Load data infile ' d:/mytable.xls ' into table mytable(name,count); The data is appended, not overwritten.
  3. Self-increment field: auto_increment, primary key: Primary_key
  4. LOADDATA[low_priority | CONCURRENT] [LOCAL]INFILE'file_name'    [REPLACE | IGNORE]     into TABLETbl_name[CHARACTER SET charset_name]    [{fields | COLUMNS} [TERMINATED by ' string ']        [[Optionally]Enclosed by 'Char']        [escaped by ' char ']    ]    [LINES [Starting by ' string ']        [TERMINATED by ' string ']    ]    [IGNORE Number {LINES | ROWS}]    [(Col_name_or_user_var [, Col_name_or_user_var] ...)] [SET col_name={expr | DEFAULT}, [, col_name={expr | DEFAULT}]...]

In MySQL, the Export and import of Excel file data

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.