Get the App
SLTechnology News&Howtos  ›  Database  › 

How MYSQL uses infile/outfile

Shulou Source: shulou.com Published: 2022-05-31 15:44:33 09月29日 Update

This article is about how MYSQL uses infile/outfile. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

As the existing employer requires the use of MYSQL database, so recently also began to further research on MYSQL database, the first intervention is, of course, some normal applications:

The flexibility of outfile/infile:

Today, when we come into contact with outfile and infile under mysql, it feels very appropriate and actual use. Unlike ORACLE, any operation has to be encapsulated into its own interface to achieve and operate. MYSQL directly completes the import and export of data through a simple statement, satisfying daily flexibility and controllability.

LOAD DATA [LOW_PRIORITY | CONCURRENT] [LOCAL] INFILE 'file_name.txt' [REPLACE | IGNORE] INTO TABLE tbl_name [FIELDS [TERMINATED BY' string'] [[OPTIONALLY] ENCLOSED BY 'char'] [ESCAPED BY' char']] [LINES [STARTING BY 'string'] [TERMINATED BY' string']] [IGNORE number LINES] [(col_name_or_user_var) .)] [SET col_name = expr,...)] demo: example file: e.txt==1 21 21 23 41 23 43 4 examples: e.txt==1 21 21 23 41 23 43 4 magic Magicum > load data infile 'dburee.txt'into table test1;Query OK, 7 rows affected (0.13 sec) Records: 7 Deleted: 0 Skipped: 0 Warnings: 0mysql > load data infile 'dpiste.txt'replace into table test1;Query OK, 7 rows affected (0.06 sec) Records: 7 Deleted: 0 Skipped: 0 Warnings: 0mysql > load data infile 'dpurab' replace into table test1 FIELDS TERMINATED by', 'LINES TERMINATED by' '; Query OK, 2 rows affected (0.09 sec) Records: 2 Deleted: 0 Skipped: 0 Warnings: 0mysql > load data infile'dvie e.txt' replace into table test1 FIELDS TERMINATED by', 'LINES TERMINATED by'; 'ignore 2Query OK, 0 rows affected (0.00 sec) Records: 0 Deleted: 0 Warnings: 0outfilemysql > select * into outfile'dburet out1.txt' from test1;Query OK, 23 rows affected (0.00 sec) mysql > select * into outfile'dpurl out2.txt`FIELDS TERMINATED by', 'from test1-> Query OK, 23 rows affected (0. 00 sec) mysql > select * into outfile'ddisplay out3.txt 'FIELDS TERMINATED by', 'lines terminated by'; 'from test1->; Query OK, 23 rows affected (0.02 sec) Thank you for reading! This is the end of this article on "how MYSQL uses infile/outfile". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!

Tags: Data content database more articles good practical relevant owner controllability business reality sense interface files articles flexibility see knowledge examples Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Shulou Technology Linux Shulou Tech Info Xiaomi