人妖在线一区,国产日韩欧美一区二区综合在线,国产啪精品视频网站免费,欧美内射深插日本少妇

新聞動(dòng)態(tài)

SQLServer 觸發(fā)器 數(shù)據(jù)庫(kù)進(jìn)行數(shù)據(jù)備份

發(fā)布日期:2022-02-01 08:33 | 文章來源:源碼中國(guó)
復(fù)制代碼 代碼如下:

  create table test3(id int primary key not null
  identity(1,1),uname varchar(20),uage int);
  create table test3_bak(id int primary key not
  null identity(1,1),bid int,uname varchar(20),
  uage int,active char(1));

  第二步,編寫備份用的觸發(fā)器,只有更新或者是插入的時(shí)候才觸發(fā)
復(fù)制代碼 代碼如下:

  alter trigger test3_bak_insert_update
  on test3
  for insert,update
  as
  declare @id int
  declare @uname varchar(20)
  declare @uage int
  begin
  select @id=id,@uname=uname,@uage=uage from inserted
  if @id<>0
  begin
  update test3_bak set active='0' where bid=@id
  insert into test3_bak(bid,uname,uage,active)
  values(@id,@uname,@uage,'1')
  end
  end

  第三步,測(cè)試數(shù)據(jù):
復(fù)制代碼 代碼如下:

  insert into test3(uname,uage) values('FLB',20)
  insert into test3(uname,uage) values('FLB1',21)
  insert into test3(uname,uage) values('FLB2',22)
  update test3 set uage=100 where id=27
  delete from test3 where id=20

  最后,你可自己采用下面方法查詢跟蹤兩個(gè)表的數(shù)據(jù)變化:
復(fù)制代碼 代碼如下:

  select * from test3
  select * from test3_bak

美國(guó)服務(wù)器租用

版權(quán)聲明:本站文章來源標(biāo)注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請(qǐng)保持原文完整并注明來源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非www.sddonglingsh.com所屬的服務(wù)器上建立鏡像,否則將依法追究法律責(zé)任。本站部分內(nèi)容來源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來,僅供學(xué)習(xí)參考,不代表本站立場(chǎng),如有內(nèi)容涉嫌侵權(quán),請(qǐng)聯(lián)系alex-e#qq.com處理。

相關(guān)文章

實(shí)時(shí)開通

自選配置、實(shí)時(shí)開通

免備案

全球線路精選!

全天候客戶服務(wù)

7x24全年不間斷在線

專屬顧問服務(wù)

1對(duì)1客戶咨詢顧問

在線
客服

在線客服:7*24小時(shí)在線

客服
熱線

400-630-3752
7*24小時(shí)客服服務(wù)熱線

關(guān)注
微信

關(guān)注官方微信
頂部