更新數據使用的是【update】命令。
4.8.1 直接賦值更新
1. 語法
update 數據表
set 字段名1=新的賦值,字段名2=新的賦值,……
where 條件
2. 實例
在【命令編輯區】執行以下語句。
―――――――――――――――――――――――――――――――――――――
update scott.emp
set empno=8888,ename='TOM',hiredate='03-9月 -2002 '
where empno=7566;
―――――――――――――――――――――――――――――――――――――【參見光盤文件】:\第4章\4.8\481.sql。
單擊【執行】按鈕,出現如圖4.49所示的結果。

4.8.2 嵌套更新
1. 語法
update 數據表
set 字段名1=(select 字段列表 from 數據表 where 條件),字段名2=(select 字段列表 from 數據表 where 條件),……
2. 實例
在【命令編輯區】執行以下語句。
―――――――――――――――――――――――――――――――――――――
update scott.emp
set sal=
(
select sal+300 from scott.emp
where empno=7599
)
where empno=7599;
―――――――――――――――――――――――――――――――――――――【參見光盤文件】:\第4章\4.8\482.sql。
單擊【執行】按鈕,出現如圖4.50所示的結果。

以上我們學習了如何利用SQL對數據表中的數據進行錄入、刪除、更新和查詢操作。讀者利用這些實例可以結合自己的實際快速掌握這些基本的數據管理語句。