Mysql text file import and batch processing mode application Instructions _mysql

Source: Internet
Author: User
Tags mysql in mysql text table definition
1 loading records in a text file into a MySQL database table
(1) Text file format: One record per line, the field values are separated by the tab locator, the field order is the same as the order in the table definition, and the indeterminate field values are represented by \ n;
(2) LOAD DATA local INFILE ' pet.txt ' into TABLE pet;
Note: If you are using a Windows editor, you should use the following:
LOAD DATA local INFILE ' pet.txt ' into TABLE pet
LINES terminated by ' \ r \ n ';

Running MySQL in 2 batch mode
(1) Put the MySQL statement you want to run in a text file batch-file.txt;
(2) Implementation: Mysql-h Host-u user-p < batch-file.txt;
(3) Redirect output to file OUT.txt:
Mysql-h host-u user-p < batch-file.txt > out.txt;
To run a script from the MySQL prompt:
Mysql> source Batch-file.txt, or mysql> \. Batch-file.txt;
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.