Export table records how to insert into mysql using mysql query browser?

how to export table records as insert in mysql using mysql query browser?

is there any other tool that can do this?

+3
source share
2 answers

The old school way is to use string concatenation:

SELECT CONCAT('INSERT INTO YOUR_TABLE (col1, col2) VALUES(', t.col1,',', t.col2, ')')
  FROM YOUR_TABLE t

Copy the output to a script. Keep in mind that you will have to process data types accordingly (IE date and time).

But I have to wonder why you are not just using mysqldump, and get the INSERT statement from the table backup.

+1
source

You can use the mysqldump utility if you have access to it. An example would be

C:\mydir> mysqldump <database> -u<username> -p<password> -t -n -c <table>
+4
source

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


All Articles