Documentation
 
 
 

1.8. Updates

You can update existing rows using the UPDATE command. Suppose you discover that all the employees hired after January 25, 1984 have their salaries offset by 100. Then you may update the data as follows:


UPDATE emp
SET sal = sal + 100
WHERE hiredate > TO_DATE('1984-01-25 00:00:00','YYYY-MM-DD hh24:mi:ss');

Look at the new state of the data:

SELECT * FROM emp
WHERE hiredate > TO_DATE('1984-01-25 00:00:00','YYYY-MM-DD hh24:mi:ss');

 empno | ename |   job   | mgr  | hiredate  |   sal   | comm | deptno
-------+-------+---------+------+-----------+---------+------+--------
  7788 | SCOTT | ANALYST | 7566 | 19-APR-87 | 3200.00 |      |     20
  7876 | ADAMS | CLERK   | 7788 | 23-MAY-87 | 1300.00 |      |     20
(2 rows)

 
 ©2004-2007 EnterpriseDB All Rights Reserved