views:

54

answers:

2

my table is:

[tableAbc]
A B C
------------
1 a b
2 c e
3 e r
...

run:

show create table tableAbc;

to get the create table sql

but how to get insert sql?

like:

insert into `tableAbc` ('A','B','C') VALUES(1,'a','b');
...

any idea? (or any java library to do this)

thanks all!

BTW: i want show the "insert sql" to web brower. so,i think i need get "insert sql" under java, or sql commands.

A: 

If you use Squirrel (A SQL tool) it can generate this for you.
I use this tool daily (it is free and it works well)

As per their description

SQuirreL SQL Client is a graphical Java program that will allow you to view the structure of a JDBC compliant database, browse the data in tables, issue SQL commands etc,

To get the insert statement for a table just right click on a table and select "data scripts"

Romain Hippeau
i will try it,thank you! ^,^oh my god,29.2MB...
Zenofo
A: 

Your question is difficult to understand due to everything being in sentence-fragments, but I think you're basically just looking for a way to be able to send SQL statements to your SQL database from Java, specifically an insert statement?

If this is the case, Java has an sql package. You can create a connection to your database, create a statement, and execute it. This will then return a ResultSet which is the result of the executed statement. Start here perhaps? http://java.sun.com/j2se/1.4.2/docs/api/java/sql/Connection.html#createStatement%28%29 And there is part of an example on the documentation for ResultSet http://java.sun.com/j2se/1.4.2/docs/api/java/sql/ResultSet.html

What do you mean by "i want to show the insert sql in the browser"? Do you mean you want to show what the result of the executed statement is?

Loduwijk