How to dump a temporary MySQL table to a file?

Is there a way to dump / export / save a temporary MySQL table to a file on disk (a .sql file that looks like a file created by mysqldump)?

+4
source share
1 answer

Sorry, I didn’t read the question correctly the first time ... anyway, the best I can come up with is to use a SELECT ... INTO OUTFILE , for example:

 SELECT * INTO OUTFILE 'result.csv' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' FROM temp_table; 

This has many limitations, for example, it deletes only raw data without including field headers. Another thing that I discovered may or may not be useful is the SHOW CREATE TABLE statement. If you can find some way to combine the output of these two statements, you can get the correct dump file created by my team below.


You can use the mysqldump application:

 mysqldump --databases temptable > file.sql 

This will reset the table with the CREATE slowdowns.

+1
source

Source: https://habr.com/ru/post/1307974/


All Articles