Mysql Data Import and Export instances

Source: Internet
Author: User
Tags field table mysql tutorial

The field table is not specified, So load data infile expects the input row to contain a field for each table column. Use the default fields and lines values.

If you want to load only some columns of a table, specify a field table:

Mysql tutorial> load data infile 'persondata.txt'
Into table persondata (col1, col2 ,...);

If the field order in the input file is different from the column order in the table, you must specify a field table. Otherwise, mysql cannot know how to match the input fields and columns in the table.

If a row has very few fields, it is set as the default value for columns without input fields.


Select <columns>
From <table_name>
Into outfile <file_name>
 
Select
Employee. id,
Employee. first_name,
Employee. last_name,
Employee. start_date,
Employee. salary,
Employee. city
From employee into outfile 'C: employee.txt ';

Import

Load data infile 'file_name.txt'
Into table tbl_name (field1, field2. .. etc)
 
Load data infile 'C: employee.txt'
Into table employee (id, first_name, last_name, start_date, salary, city );


 
Import from File

Mysql> load data local infile 'C: mytable.txt 'into table mytable lines terminated by 'rn ';


Mysql>

 

 

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.