sql 語句 查詢

2021-04-13 08:07:27 字數 1862 閱讀 6577

【例11.1】

(1)use xk

gocreate trigger test1

on student

for update

as print '記錄已修改!'

go(2)

update student set pwd='11111111' where stuno='00000001'

【例11.3】

(1)use xk

goalter trigger test1

on student

instead of update

as print '記錄沒有修改!'

go(2)

update student set pwd='22222222' where stuno='00000001'

【例11.4】

(1)use xk

gocreate trigger setwillnum on stucou

for insert, update, delete

asupdate course set willnum=willnum+1 where couno=(select couno from inserted)

update course set willnum=willnum-1 where couno=(select couno from deleted)

(2)select * from course where couno='002'

select * from course where couno='003'

(3)update stucou set couno='002' where stuno='00000011' and couno='003'

(4)select * from course where couno='002'

select * from course where couno='003'

(5)use xk

goalter trigger setwillnum on stucou

for insert, update, delete

asupdate course set willnum=(select count(*) from stucou where couno=course.couno)

【例11.5】

use xk

goalter trigger test1

on student

for update

as if update(pwd) print '密碼已修改!'

go【例11.6】

use xk

gocreate trigger test2

on student

for update

as print '二次觸發!'

go測試:

update student set pwd='22222222' where stuno='00000001'

【例11.7】

use xk

drop trigger test1

【例11.9】

use xk

gosp_rename setwillnum,updatewillnum

【例11.10】

use xk

goalter table stucou disable trigger updatewillnum

【例11.11】

use xk

goalter table stucou enable trigger updatewillnum

【例11.12】

use xk

goselect * from sysobjects where type='tr'

SQL查詢語句

create or replace procedure imms pk reportsend fromdate varchar2,todate varchar2 as function 系統效能統計 author qja 功能 將imms statusreport 表和imms report sen...

sql查詢語句

條件查詢 select 列名列表 from 表名 where 條件 where 條件 用來篩選滿足條件的記錄 行 條件有6種形式 1.比較大小 列名 比較運算子 值 查詢圖書 超過30元的圖書資訊 select from book where price 30 查詢清華大學出版社出版的圖書資訊 se...

SQL查詢語句

sql查詢語句 select from film order by year limit 10 select from film order by year desc limit 10 select count from film select from film where starring li...