# 8. SQL Reference

Chapter Contents | Prev | Next
Keyword Search:
www.openlinksw.com
docs.openlinksw.com
Book Home
Contents
Preface
SQL Reference
Datatypes
User Defined Types
XML Column Type
Identifier Case & Quoting
Wide Character Identifiers
Qualified Names
Literals, Brace Escapes
CREATE TABLE Statement
DROP TABLE Statement
CREATE INDEX Statement
DROP INDEX Statement
ALTER TABLE Statement
CREATE VIEW Statement
CREATE XML SCHEMA Statement
DROP XML SCHEMA Statement
Sequence Objects
INSERT Statement
UPDATE Statement
SELECT Statement
COMMIT WORK, ROLLBACK WORK Statement
CHECKPOINT, SHUTDOWN Statement
Stored Procedures as Views & Derived Tables
GRANT, REVOKE Statement
SET Statement
Best Effort Union
Standard and User-Defined Aggregate Functions
Virtuoso SQL Optimization
SQL Inverse Functions
SQL Grammar
Bitmap Indices

## 8.18. UPDATE Statement

Existing rows (or records) are changed in the database using the UPDATE statement.

NULL values can be utilized using the NULL keyword without any quotes. Since NULL is a special keyword you do not need to enclose it in single quotes, doing so will cause it be read as a string-literal.

The update statement is made up by selecting the table to update, the search condition that identifies which rows you want to update, and the column=value of each column you wish to change.

Basic Update Statement

A table can be updated using:

    update demo.dba.employees e
      set username = 'thing'
      where email_address = 'thing@thingdom.com'
      ;

Update from Select

It is possible to update one table based on a select from another table. Ensure that the selection is properly conditioned to update.

    update demo.dba.employees e
    	set username = (select U_NAME from DB.DBA.SYS_USERS u where u.U_EMAIL = e.email_address)
    	;

Previous INSERT Statement | Chapter Contents | Next SELECT Statement