In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the effective methods of exporting the query results of mysql to csv, hoping to add and update some knowledge, if you have other questions to understand, you can continue to follow my updated article in the industry information.
To export the query results of mysql to csv, you typically use php connection mysql to execute the query and generate the returned query results using php to generate csv format and then export.
But this is troublesome, and you need to install php on the CVM to achieve this.
Export csv methods directly using mysql
We can use into outfile, fields terminated by, optionally enclosed by, line terminated by statements to implement export csv
The format and function of sentences
Into outfile 'exported directories and filenames'
Specify the exported directory and file name
Fields terminated by 'field delimiter'
Define delimiters between fields
Optionally enclosed by 'field bounding character'
Define the characters that surround the field (numeric field is not valid)
Lines terminated by 'line delimiter'
Define the delimiter for each line
Example: mysql-u rootuse test;select * from table into outfile'/ tmp/table.csv' fields terminated by', 'optionally enclosed by' "'lines terminated by'\ r\ n'
After execution, the recorded data in talbe is exported to the / tmp/table.csv file. Each field is separated by, the field content is surrounded by a string, and each record is wrapped with\ r\ nnewline.
This article explains the method of exporting query results to csv through mysql. Please follow us for more information.
Related recommendations:
Performance comparison between php array_push and $arr [] = $value
How to use php to set up a session that strictly controls the expiration time
How to use php to judge whether memcache key/value exists or not
These are the details of the effective methods for exporting mysql query results to csv. Please pay attention to other related articles for more information.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.