INSERT Statement

The INSERT statement supported by UnityJDBC has the following syntax:

INSERT INTO <tbl_name> [(<col_name>,...)] VALUES <exprList>;

Specifying column names is optional. An example is below:

INSERT INTO mydb.Customer (id,firstname,lastname,street,city) 
       VALUES (52,'Fred','Jones','Smith Lane', 'Chicago');

UnityJDBC also supports INSERT INTO ... SELECT with the following syntax:

INSERT INTO <tbl_name> [(<col_name>,...)] VALUES <exprList>
(SELECT <query>);

This is useful for storing query results into another table. Note that this table and all its column must already exist or an error will be returned. Here is an example:

INSERT INTO emptydb.customer (SELECT * FROM mydb.customer);