欧美大屁股bbbbxxxx,狼人大香伊蕉国产www亚洲,男ji大巴进入女人的视频小说,男人把ji大巴放进女人免费视频,免费情侣作爱视频

歡迎來到入門教程網(wǎng)!

MsSql

當(dāng)前位置:主頁 > 數(shù)據(jù)庫 > MsSql >

Sqlserver事務(wù)備份和還原的實(shí)例代碼(必看)

來源:本站原創(chuàng)|時(shí)間:2020-01-10|欄目:MsSql|點(diǎn)擊: 次

廢話不多說,直接上代碼

create database mydb
use mydb
go
create table account(
  id varchar(16),
  name varchar(16),
  balance float
)
go
select * from account

insert into account(id, name, balance) values('620101', 'liyong', 300)
insert into account(id, name, balance) values('620106', 'mali', 400)
--insert into account(id, name, balance) values('620009', 'chenying', 800)
insert into account(id, name, balance) values('646009', 'chenying', 800)
--delete from account where id = '620009'
go
update account set balance = balance - 1000 where id = '620101'
update account set balance = balance + 1000 where id = '620106'
--消息 547,級(jí)別 16,狀態(tài) 0,第 1 行
--UPDATE 語句與 CHECK 約束"CK_Blance"沖突。該沖突發(fā)生于數(shù)據(jù)庫"mydb",表"dbo.account", column 'balance'。
--語句已終止。

go
--alter table account
--alter COlumn balance int
go
alter table account
add constraint CK_Blance check(balance >= 0)
go
alter table account
drop constraint CK_Blance
--定一個(gè)事務(wù)
--從liyong扣錢往mali加錢
begin transaction
update account set balance = balance - 1000 where id = '620101'
if((select balance output from account where id = '620101') < 0)
begin
PRINT('余額不足!');
ROLLBACK;
end
else
begin
  update account set balance = balance + 1000 where id = '620106'
  commit;
  PRINT('轉(zhuǎn)賬成功!');
end
go
sp_help
--備份設(shè)備
sp_addumpdevice 'disk', 'xk_bak' ,'d:\xk_bak'
--備份數(shù)據(jù)庫
backup database mydb
to xk_bak
--還原數(shù)據(jù)庫
restore database mydb from disk = 'd:\xk_bak'
with replace; --覆蓋

以上這篇Sqlserver事務(wù)備份和還原的實(shí)例代碼(必看)就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持我們。

網(wǎng)頁制作CMS教程網(wǎng)絡(luò)編程軟件編程腳本語言數(shù)據(jù)庫服務(wù)器

如果侵犯了您的權(quán)利,請(qǐng)與我們聯(lián)系,我們將在24小時(shí)內(nèi)進(jìn)行處理、任何非本站因素導(dǎo)致的法律后果,本站均不負(fù)任何責(zé)任。

聯(lián)系QQ:835971066 | 郵箱:835971066#qq.com(#換成@)

Copyright © 2002-2020 腳本教程網(wǎng) 版權(quán)所有