SQL Insert Statement


Inserts a record into a table

Syntax

INSERT [IGNORE] INTO table_name (column [,column...]) VALUES (expression [,expression...])
table_name:  name of the table to insert the record into
column:  column to insert
expression:  value to insert. May be parameter or constant
parameter:  the literal "?"
constant:  String, double, long, etc..
IGNORE:  Ignore unique constrain violations. This behaves like an upsert.

Example

PreparedStatement stmt = conn.prepareStatement("insert ignore into persons (name, age, occupation) values ('bob', ?, ?)")
stmt.setInt(1, 30);
stmt.setString(2, "artist");
stmt.executeUpdate();