If we execute the same statement again, MySQL produces an error message that can be seen in the below output: It is because the specified table contains six rows only. We will get the following output, where we can see that six rows are affected. INTO OUTFILE 'C:/ProgramData/MySQL/MySQL Server 8.0/Uploads/employee_backup.csv' SELECT Id, Name, Email, Phone, City FROM employee_detail To export the table data into a CSV file, we need to execute the query as follows: If we execute the SELECT statement, we will see the following output: Export MySQL data in CSV format using the SELECT INTO. INSERT INTO employee_detail ( Id, Name, Email, Phone, City) It is to ensure that we have a file privilege to use this syntax. This statement is a compliment of the LOAD DATA command, which is used to write data from a table and then export it into a specified file format on the server host. To export the table into a CSV file, we will use the SELECT INTO.OUTFILE statement. The specified CSV file should not exist in the system.The MySQL server's process has the read/write access to the specified (target) folder, which contains the CSV file.We must ensure the following things before exporting MySQL data: MySQL provides an easy way for exporting any table into CSV files resides in the database server. It is a plaintext file that helps us to export data very easily. It is useful to have MySQL data in CSV file format that allows us to analyze and format them in the way we want. A CSV file format is a comma-separated value that we use to exchange data between various applications such as Microsoft Excel, Goole Docs, and Open Office. MySQL has a feature to export a table into the CSV file.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |