How to change the format of a query result?

0

I would like to know if there is any argument in the select that changes the result format to be used as dump . Example:

create table 'table_name' ('id' int, 'value' text);
insert into 'table_name' values (1, "a"), (2, "b"), (3, "c");

select * from 'table_name';
/* Result: "insert into 'table_name' values (1, "a"), (2, "b"), (3, "c")" */
    
asked by anonymous 07.12.2016 / 18:24

2 answers

1

Paul, I've never seen any function in a database that does what you want, but you can get the similar result by mounting the sql within the select using the concat () function, with this example you would look like this: / p>

select concat('insert into table_name values (',id,',',value,');') from table_name;

Each row of the result will be an insert with a table record.

    
07.12.2016 / 18:58
0

I am not aware of this function of generating the insert by SQL.

However, MySql Workbench after script execution has the option of exporting to various formats: CSV, HTML, JSON, SQL INSERT and so on.

    
07.12.2016 / 19:06