1
我有一個emp
表,這些列如何更新基礎上的Oracle SQL語法其他表中的列值
emp_id f_name l_name salary dept_id
----------------------------------------------------
100 Steven King 24000 90
101 Neena Kochhar 17000 50
102 Lex De Haan 17000 90
103 Alexander Hunold 9000 60
現在我有t_emp
表,這些列:
f_name l_name salary dept_id
-------------------------------------------
Steven King 24000 null
Neena Kochhar 17000 null
Lex De Haan 17000 null
Alexander Hunold 9000 null
假設最近在這裏添加了dept_id
列。我想更新t_emp.dept_id
列與emp.dept_id
列相同。 我怎麼能這樣做?
當我嘗試下面insert into
查詢時,收到錯誤消息:
不能插入NULL到( 「高拉夫」 「T_EMP」 「LAST_NAME」。)
insert into t_emp(dept_id)
select dept_id
from emp;
怎麼可能我在t_emp
表中根據emp
表做這個單列更新嗎?
'INSERT'創建新行。如果你想更新現有的行,使用'UPDATE'(或可能'MERGE') –