October 2005
Intermediate to advanced
454 pages
14h 44m
English
You can update one or more columns in one or more rows using the UPDATE statement . Here is the basic syntax :
UPDATEtableSETcol1 = val1[,col2 = val2, ... colN = valN] [WHEREWHERE_clause];
The WHERE clause is optional; if you do not supply one, all rows in the table are updated. Here are some examples of UPDATEs:
Uppercase all the titles of books in the book table.
UPDATE books SET title = UPPER (title);
Run a utility procedure that removes the time component from the publication date of books written by specified authors (the argument in the procedure) and uppercases the titles of those books. As you can see, you can run an UPDATE statement standalone or within a PL/SQL block:
CREATE OR REPLACE PROCEDURE remove_time (
author_in IN VARCHAR2)
IS
BEGIN
UPDATE books
SET title = UPPER (title),
date_published =
TRUNC (date_published)
WHERE author LIKE author_in;
END;