How To Update Values on Multiple Rows in Oracle?
Submitted by: AdministratorIf the WHERE clause in an UPDATE matches multiple rows, the SET clause will be applied to all matched rows. This rule allows you to update values on multiple rows in a single UPDATE statement. Here is a good example:
UPDATE ggl_links SET counts = 9, notes = 'Wrong URL'
WHERE id >= 250;
3 rows updated.
SELECT * FROM ggl_links WHERE id >= 250;
<pre> ID URL NOTES COUNTS CREATED
----- -------------------- ------------ ------- ---------
250 Retail Sales.com Wrong URL 9 07-MAY-06
260 Recruiting.com Wrong URL 9 07-MAY-06
270 Payroll.com Wrong URL 9 07-MAY-06</pre>
This statement updated 3 rows with the same new values on all 3 rows.
Submitted by: Administrator
UPDATE ggl_links SET counts = 9, notes = 'Wrong URL'
WHERE id >= 250;
3 rows updated.
SELECT * FROM ggl_links WHERE id >= 250;
<pre> ID URL NOTES COUNTS CREATED
----- -------------------- ------------ ------- ---------
250 Retail Sales.com Wrong URL 9 07-MAY-06
260 Recruiting.com Wrong URL 9 07-MAY-06
270 Payroll.com Wrong URL 9 07-MAY-06</pre>
This statement updated 3 rows with the same new values on all 3 rows.
Submitted by: Administrator
Read Online Oracle Database Job Interview Questions And Answers
Top Oracle Database Questions
☺ | How To Use Values from Other Tables in UPDATE Statements using Oracle? |
☺ | What Happens to Indexes If You Drop a Table? |
☺ | How To Add a New Column to an Existing Table in Oracle? |
☺ | How To Invoke the Data Pump Import Utility? |
☺ | How To Recover a Dropped Table in Oracle? |
Top DB Oracle Categories
☺ | Oracle PL-SQL Interview Questions. |
☺ | Oracle DBA Interview Questions. |
☺ | Oracle D2K Interview Questions. |
☺ | OCI Interview Questions. |
☺ | Oracle RMAN Interview Questions. |