12.07.2015 Views

Oracle SQL Developer

Oracle SQL Developer

Oracle SQL Developer

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Transaction Control Statements6.3.2 Updating Data With the UPDATE StatementYou can use the <strong>SQL</strong> UPDATE statement to update data in a row of a table. Theupdated data must be valid for the data type and size of each column of the table.Example 6–9 shows how to use UPDATE to update data in the employees table. Notethe use of the use of multiplication operator * to calculate a new salary. Forinformation on arithmetic operators, See "Using Arithmetic Operators" on page 6-12.Example 6–9Using the UPDATE StatementSELECT salary FROM employees WHERE employee_id = 301;-- update the salary for employee 301, multiply the salary by 105%UPDATE employees SET salary = salary * 1.05 WHERE employee_id = 301;-- the following should show a change in salarySELECT salary FROM employees WHERE employee_id = 301;See Also:■ <strong>Oracle</strong> Database <strong>SQL</strong> Reference for information on the UPDATEstatement.6.3.3 Deleting Data With the DELETE StatementWith the <strong>SQL</strong> DELETE statement you can delete all or specific rows in a table.When you delete all the rows in a table, the empty table still exists. If you want toremove the entire table from the database, use the <strong>SQL</strong> DROP statement. See "Droppinga Table With <strong>SQL</strong>" on page 6-17.Example 6–10 shows how to use DELETE to delete selected rows in the employeestable. Note the use of the WHERE clause. Without that clause, all the rows would bedeleted.Example 6–10 Using the DELETE StatementDELETE FROM employees WHERE employee_id = 300 OR employee_id = 301;-- the following query should not find any recordsSELECT * FROM employees WHERE employee_id = 300 OR employee_id = 301;If you accidentally delete rows, you can restore the rows with the ROLLBACKstatement. See "Rolling Back a Transaction" on page 6-9.See Also:■<strong>Oracle</strong> Database <strong>SQL</strong> Reference for information on the DELETEstatement.6.4 Transaction Control StatementsTransaction control statements manage the changes made by DML statements andgroup DML statements into transactions. They enable you to:■■Make a transaction's changes permanent (COMMIT)Undo the changes in a transaction, either since the transaction started or since asavepoint (ROLLBACK)6-8 <strong>SQL</strong> <strong>Developer</strong> Online Help

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!