這篇文章主要講解了“數(shù)據(jù)庫(kù)觸發(fā)器舉例分析”,文中的講解內(nèi)容簡(jiǎn)單清晰,易于學(xué)習(xí)與理解,下面請(qǐng)大家跟著小編的思路慢慢深入,一起來(lái)研究和學(xué)習(xí)“數(shù)據(jù)庫(kù)觸發(fā)器舉例分析”吧!
汪清網(wǎng)站制作公司哪家好,找創(chuàng)新互聯(lián)公司!從網(wǎng)頁(yè)設(shè)計(jì)、網(wǎng)站建設(shè)、微信開發(fā)、APP開發(fā)、成都響應(yīng)式網(wǎng)站建設(shè)公司等網(wǎng)站項(xiàng)目制作,到程序開發(fā),運(yùn)營(yíng)維護(hù)。創(chuàng)新互聯(lián)公司于2013年創(chuàng)立到現(xiàn)在10年的時(shí)間,我們擁有了豐富的建站經(jīng)驗(yàn)和運(yùn)維經(jīng)驗(yàn),來(lái)保證我們的工作的順利進(jìn)行。專注于網(wǎng)站建設(shè)就選創(chuàng)新互聯(lián)公司。
我們維護(hù)一張客戶表,這張表的內(nèi)容在周六和周日不允許修改。這就是客戶表:
CREATE TABLE plch_customers ( custnum INTEGER , custname VARCHAR2 (100) )
我需要?jiǎng)?chuàng)建一個(gè)觸發(fā)器來(lái)阻止周末對(duì)這張表的任何插入、修改和刪除。我寫了這些代碼:
CREATE OR REPLACE TRIGGER plch_customers_maint_trg /*TEXT*/ DECLARE BEGIN IF TO_CHAR (SYSDATE, 'DY', 'NLS_DATE_LANGUAGE=ENGLISH') IN ('SAT', 'SUN') THEN RAISE_APPLICATION_ERROR (-20000 , 'Customers maintained Monday-Friday only.'); END IF; END; /
哪些選項(xiàng)可用來(lái)取代文中的/*TEXT*/, 使得這個(gè)觸發(fā)器不允許周末對(duì)plch_customers表執(zhí)行任何DML操作,并且每個(gè)語(yǔ)句只觸發(fā)一次?
(A)
BEFORE UPDATE ON plch_customers FOR EACH ROW BEFORE INSERT ON plch_customers FOR EACH ROW BEFORE DELETE ON plch_customers FOR EACH ROW
SQL> CREATE OR REPLACE TRIGGER plch_customers_maint_trg BEFORE UPDATE ON plch_customers FOR EACH ROW BEFORE INSERT ON plch_customers FOR EACH ROW BEFORE DELETE ON plch_customers FOR EACH ROW DECLARE BEGIN IF TO_CHAR (SYSDATE, 'DY', 'NLS_DATE_LANGUAGE=ENGLISH') IN ('SAT', 'SUN') THEN RAISE_APPLICATION_ERROR (-20000 , 'Customers maintained Monday-Friday only.'); END IF; END; ORA-04079: 無(wú)效的觸發(fā)器說(shuō)明 SQL>
(B)
BEFORE UPDATE ON plch_customers BEFORE INSERT ON plch_customers BEFORE DELETE ON plch_customers
SQL> CREATE OR REPLACE TRIGGER plch_customers_maint_trg BEFORE UPDATE ON plch_customers BEFORE INSERT ON plch_customers BEFORE DELETE ON plch_customers DECLARE BEGIN IF TO_CHAR (SYSDATE, 'DY', 'NLS_DATE_LANGUAGE=ENGLISH') IN ('SAT', 'SUN') THEN RAISE_APPLICATION_ERROR (-20000 , 'Customers maintained Monday-Friday only.'); END IF; END; ORA-04079: 無(wú)效的觸發(fā)器說(shuō)明 SQL>
(C)
BEFORE UPDATE, INSERT OR DELETE ON plch_customers
SQL> CREATE OR REPLACE TRIGGER plch_customers_maint_trg BEFORE UPDATE, INSERT OR DELETE ON plch_customers DECLARE BEGIN IF TO_CHAR (SYSDATE, 'DY', 'NLS_DATE_LANGUAGE=ENGLISH') IN ('SAT', 'SUN') THEN RAISE_APPLICATION_ERROR (-20000 , 'Customers maintained Monday-Friday only.'); END IF; END; ORA-00969: 缺失 ON 關(guān)鍵字 SQL>
(D)
BEFORE UPDATE OR INSERT OR DELETE ON plch_customers FOR EACH ROW
SQL> Trigger created SQL>
(E)
BEFORE UPDATE OR INSERT OR DELETE ON plch_customers
SQL> Trigger created SQL>
答案E
D不是答案因?yàn)槊啃卸紩?huì)觸發(fā),不滿足條件。
感謝各位的閱讀,以上就是“數(shù)據(jù)庫(kù)觸發(fā)器舉例分析”的內(nèi)容了,經(jīng)過(guò)本文的學(xué)習(xí)后,相信大家對(duì)數(shù)據(jù)庫(kù)觸發(fā)器舉例分析這一問(wèn)題有了更深刻的體會(huì),具體使用情況還需要大家實(shí)踐驗(yàn)證。這里是創(chuàng)新互聯(lián),小編將為大家推送更多相關(guān)知識(shí)點(diǎn)的文章,歡迎關(guān)注!
文章題目:數(shù)據(jù)庫(kù)觸發(fā)器舉例分析
轉(zhuǎn)載注明:http://aaarwkj.com/article6/gpjcig.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供做網(wǎng)站、軟件開發(fā)、虛擬主機(jī)、企業(yè)網(wǎng)站制作、網(wǎng)站維護(hù)、搜索引擎優(yōu)化
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
網(wǎng)頁(yè)設(shè)計(jì)公司知識(shí)