新聞中心
Oracle數(shù)據(jù)庫(kù),關(guān)于關(guān)聯(lián)兩張表更新問(wèn)題
--因?yàn)闆](méi)有給出a、b兩個(gè)表的關(guān)聯(lián),所以用a.id和b.aid做了關(guān)聯(lián)
成都創(chuàng)新互聯(lián)是一家專注于網(wǎng)站建設(shè)、成都網(wǎng)站設(shè)計(jì)與策劃設(shè)計(jì),金沙網(wǎng)站建設(shè)哪家好?成都創(chuàng)新互聯(lián)做網(wǎng)站,專注于網(wǎng)站建設(shè)十年,網(wǎng)設(shè)計(jì)領(lǐng)域的專業(yè)建站公司;建站業(yè)務(wù)涵蓋:金沙等地區(qū)。金沙做網(wǎng)站價(jià)格咨詢:18982081108
update
a
aa
set
status=30
where
(select
count(status)
from
b
where
a.id=b.aid)0
--確定b表有A表子數(shù)據(jù)
and
(select
count(status)
from
b
where
a.id=b.aid
and
b.status30)=0--b表子數(shù)據(jù)status30個(gè)數(shù)=0個(gè),說(shuō)明子數(shù)據(jù)status全部為30
oracle兩個(gè)表之間數(shù)據(jù)更新怎么實(shí)現(xiàn)
數(shù)據(jù)類型都一樣的么,可以考慮用觸發(fā)器實(shí)現(xiàn) 以oracle數(shù)據(jù)庫(kù)為例 有兩張表test和test01 字段有id name age sal
create or replace trigger TRIG_UPDATE_TEST
after insert or delete or update on test
for each row
declare
l_id varchar2(50);
l_name varchar2(50);
l_age number;
l_sal number;
begin
if(deleting or updating) then
delete test01
where id=:old.id;
if(deleting) then
return;
end if;
end if;
l_id:=:new.id;
l_name:=:new.name;
l_age:=:new.age;
l_sal:=:new.sal;
begin
insert into test01(id,name,age,sal) values(l_id,l_name,l_age,l_sal);
end;
end TRIG_UPDATE_TEST;
再簡(jiǎn)化點(diǎn)就是在觸發(fā)器中不聲明變量,直接用:new.字段代替
哎,沒(méi)分啊
請(qǐng)采納。
在oracle怎樣更新表中的數(shù)據(jù)
操作步驟如下:
準(zhǔn)備數(shù)據(jù):在excel中構(gòu)造出需要的數(shù)據(jù)
2.將excel中的數(shù)據(jù)另存為文本文件(有制表符分隔的)
3.將新保存到文本文件中的數(shù)據(jù)導(dǎo)入到pl*sql中
在pl*sql中選擇tools--text
importer,在出現(xiàn)的窗口中選擇"Data
from
Textfile",然后再選擇"Open
data
file",
在彈出的文件選擇框中選中保存有數(shù)據(jù)的文本文件,此時(shí)將會(huì)看到data
from
textfile中顯示將要導(dǎo)入的數(shù)據(jù)
4.在configuration中進(jìn)行如下配置
注:如果不將"Name
in
header"勾選上會(huì)導(dǎo)致字段名也當(dāng)做記錄被導(dǎo)入到數(shù)據(jù)庫(kù)中,從而導(dǎo)致數(shù)據(jù)錯(cuò)誤
5.點(diǎn)擊data
to
oracle,選擇將要導(dǎo)入數(shù)據(jù)的表,并在fields中將文本中的字段與表中的字段進(jìn)行關(guān)聯(lián)
6.點(diǎn)擊import按鈕進(jìn)行導(dǎo)入
7.查看導(dǎo)入的數(shù)據(jù)
OK,至此數(shù)據(jù)導(dǎo)入成功。
分享文章:oracle如何聯(lián)表更新,oracle如何更新表數(shù)據(jù)
瀏覽路徑:http://fisionsoft.com.cn/article/dscoijg.html