Modifying Rows in the Database


You use the SQL UPDATE statement to modify existing rows in a table. Just as with performing an INSERT statement with JDBC, you can use the executeUpdate() method defined in the Statement class or the execute() method defined in the PreparedStatement class. Use of the PreparedStatement class is covered later in this chapter.

The following example illustrates how to modify the row where the customer_id column is equal to 1:

 first_name = "Jean"; myStatement.executeUpdate("UPDATE customers " +  "SET first_name = '" + firstName + "' " +  "WHERE customer_id = 1"); 

Once this statement has completed, customer #1 s first name will be set to Jean .




Oracle Database 10g SQL
Oracle Database 10g SQL (Osborne ORACLE Press Series)
ISBN: 0072229810
EAN: 2147483647
Year: 2004
Pages: 217

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net