開發中偶爾需要新增一條記錄或修改一條記錄的幾個字段,語法中有微妙的區別。
由於不是經常寫,久不寫就忘記了,而又要重新查詢或除錯。
新增記錄語法:
--新增記錄(仿照已有表記錄)
insert into t_***x t
(t.field_1, t.field_2, t.field_3, t.field_4, t.field_5)
select t2.field_1, t2.field_2, t2.field_3, t2.field_4, t2.field_5
from t_yyyy t2
where t2.field_1 = 'demo';
--新增記錄(自定義值)
insert into t_***x t
(t.field_1, t.field_2, t.field_3, t.field_4, t.field_5)
values
(10000, 10000, 'demo', 'demo', sysdate);
####################淺淺的分割線####################
更新語法示例:
--更新記錄(自定義值)
update t_***x t
set t.field_1 = 'demo', t.field_2 = 'demo'
where t.field_3 = '10000';
--更新記錄(仿照已有表記錄)
update t_***x t
set (t.field_1, t.field_2) = (select t2.field_1, t2.field_2
from t_yyyy t2
where t2.field_3 = '10000')
where t.field_3 = '10000';
Oracle 記錄 持續更新
1 select distinct area.region code from tb organization org inner join tb admindivision area on org.area code area.region code 2 select distinct area....
oracle 序列 迴圈新增記錄
一點小經驗共同分享 seq bos t priv function為序列,colnum1為主鍵 insert into table1 colnum1,colnum2 values select seq bos t priv function.nextval from dual 1 insert in...
Oracle同時更新兩記錄
t check表結構,該錶主鍵為 w id rw num 要變更的記錄 業務目標為同時修改這兩條記錄的opinion欄位 當用operator為sup時將opinion改為 超級管理員 當operator為其他值是將opinion修改為 普通管理員 最終處理方法使用了case when,sql如下 ...