Skip to Main Content
Oracle PL/SQL for DBAs
book

Oracle PL/SQL for DBAs

by Arup Nanda, Steven Feuerstein
October 2005
Intermediate to advanced content levelIntermediate to advanced
454 pages
14h 44m
English
O'Reilly Media, Inc.
Content preview from Oracle PL/SQL for DBAs

The UPDATE Statement

You can update one or more columns in one or more rows using the UPDATE statement . Here is the basic syntax :

    UPDATE table
       SET col1 = val1
           [, col2 = val2, ... colN = valN]
    [WHERE WHERE_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;
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Oracle PL/SQL Best Practices

Oracle PL/SQL Best Practices

Steven Feuerstein
Expert Oracle PL/SQL

Expert Oracle PL/SQL

Ron Hardman, Michael McLaughlin
Oracle PL/SQL For Dummies

Oracle PL/SQL For Dummies

Michael Rosenblum, Paul Dorsey

Publisher Resources

ISBN: 0596005873Supplemental ContentErrata Page