views:

46

answers:

7

Hi,

Does anyone know any free tools that will generate insert statements given a result set? I know TOAD for Oracle does it, i would need this for a mysql database.

For example, if I execute this query

select colA, colB from mytable where colC = 'numbers'; //returns many rows


|colA | colB  |
|1    | 'one' |
|2    | 'two' |
|3    | 'three|

I would be able to get

insert into mytable (colA, colB) values (1,'one');
insert into mytable (colA, colB) values (2,'two');
insert into mytable (colA, colB) values (3,'three');

Thanks in advance

+1  A: 

For MySQL you cna use the LOAD DATA statement

codymanix
A: 

Try sqldeveloper . This page may help you do what exactly you are trying to do.

Gopi
A: 

HeidiSQL allows you to export whole grid or only selected rows

dev-null-dweller
+1  A: 

What's wrong with using SQL?

SELECT CONCAT(
    'INSERT INTO mytable (colA, colB) VALUES (',
    colA,
    ',\'',
    colB,
    '\';'
) AS line
FROM mytable
WHERE colC = 'numbers';

Or just skip the temp file and:

INSERT INTO dest_table (colA, colB)
SELECT colA, colB
FROM mytable
WHERE colC = 'numbers';
symcbean
A: 

IMO TOra is closet tool to TOAD. This is a very good alternative to Toad and FREE.

http://torasql.com/

YoK
+1  A: 

http://squirrel-sql.sourceforge.net/ is another tool that will allow this. It is Java based and works well for multiple databases.

Romain Hippeau
definetly a good option. Many toad fan boys here, so this wasn't chosen, but personally find it very easy to use, and particularly exporting insert statements is a 2 right click task. Thanks
Tom
+1  A: 

There is a MySQL version of TOAD. It probably has the same ability to export result sets.

nathan