SELECT into outfile backup database data

Source: Internet
Author: User


SELECT into outfile backup database data select email into outfile "test.txt" from email; select substring (boss,), addr from guest; load data [LOW_PRIORITY | CONCURRENT] [LOCAL] INFILE "/opt/abc.txt" into table table_name -www.2cto.com-fields terminated by ',' (column1, column2, colum3 ); mysql> SELECT * FROM table1 into outfile 'data.txt 'fields terminated by', 'From... to read the files separated by commas, the correct statement is: mysql> load d. Ata infile 'data.txt 'into table table2 fields terminated by', '; -www.2cto.com-if you try to read the file using the statement shown below, it will not work, the command load data infile is used to find the location between FIELDS: mysql> load data infile 'data.txt 'into table table2 fields terminated by' \ T '; the possible result is that each input row is interpreted as a single field. Load data infile can be used to read files obtained from external sources. For example, a file in dBASE format will have fields separated by commas and enclosed by double quotation marks. If the row in the file is terminated by a line break, the following command shows the FIELDS and row processing options you will use to LOAD the file: mysql> load data infile 'data.txt 'into TABLE tbl_name fields terminated ', 'enabledby' "'Lines terminated by '\ n'; -www.2cto.com-any field or row processing option can specify an empty string (''). If it is not null, the value of FIELDS [OPTIONALLY] enclosed by and fields escaped by must be a single character. Fields terminated by and lines terminated by values can be over one character. For example, write a line terminated by the carriage return or read a file containing such a line and specify a line terminated by '\ r \ n' clause. -Www.2cto.com-FIELDS [OPTIONALLY] enclosed by control field surrounded BY characters. For output (SELECT... into outfile), if OPTIONALLY is omitted, all fields are surrounded by enclosed by characters. An example of such output (using a comma as the field separator) is shown below: "1", "a string", "100.20" "2 ", "a string containing a, comma", "102.20" "3", "a string containing a \" quote "," 102.20 "" 4 ", "a string containing a \", quote and comma "," 102.20 "======================= insert into tabl (id, email) select id, email from guest; author huimai

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.