update Shippers --1.被修改的資料表
set phone = 09999999--3.把符合條件的欄目修改成新的資料
where company = 'aaa'--2.被修改的資料條件,修改company = 'aaa'的資料
修改前:
1 | aaa | 0932556677 |
修改後:
1 | aaa | 09999999 |
可以在set中加入子查詢,所以就是把EMPLOYEE_ID = 14的人的ID改成AC_MGR,並且把他的薪水也改成12000,大概是這傢伙調職務了我猜~
update EMPLOYEES
set JOB_ID = (select JOB_ID from EMPLOYEES where EMPLOYEE_ID = 205),--AC_MGR
salary = (select salary from EMPLOYEES where EMPLOYEE_ID = 205)--12000
where EMPLOYEE_ID = 14
把欄位設定成預設值:
UPDATE DEPARTMENTS
set MANAGER_ID = default
where DEPARTMENT_ID = 10
刪除資料
delete from EMPLOYEES
where EMPLOYEE_ID = 113
一樣可以加入子查詢:
delete from EMPLOYEES
where DEPARTMENT_ID = (select DEPARTMENT_ID
from DEPARTMENTS
where DEPARTMENT_name like '%T')
刪除所有資料,只留下資料結構:TRUNCATE
truncate table shippers
select * from shippers
(只剩下欄目名稱,資料已全數被刪除)
刪除整個資料表:Drop
drop table shippers
select * from shippers
訊息 208,層級 16,狀態 1,行 1
無效的物件名稱 'shippers'。
留言列表