SQL Server2008新功能 捕获数据变化3
2008-02-29 11:42:54 来源:IT专家网 作者:Jackie 点击:
捕获数据变化功能可以方便地监控到表的变化。本文的第一、二部分介绍了怎样在数据库及表上开启捕获数据变化功能。下面将介绍的是,如果表的结构发生变化,捕获数据变化功能将有什么样的表现。
第五步
开启了捕获数据变化功能后,在表“Employee”上增加几列,如下:
use [CDCDB]
go
GO
Alter Table Employee add Address varchar(500)
GO
Alter Table Employee add Salary money
GO
Alter Table Employee add Bonus money
GO |
第六步
向表中插入一些数据。
|
use [CDCDB]
go
select * from Employee
go
Insert into Employee values (1, 'Dancing Doll','221, West Broad st,
Greenbay, Wisconsin',60000,1000)
Insert into Employee values (2, 'Rainbow Dance','21, East st,
Denville, New Jersey',68000,1300)
Insert into Employee values (3, 'Water Dance','1, South Broad st,
Quincy, Massachusetts',76000,1600)
Insert into Employee values (4, 'Mickey Mouse','5, Main,
Greenbay, Wisconsin',120000,12000)
Insert into Employee values (5, 'Rat year','7, New road,
Danbury , Connecticut',45000,1600)
go
select * from Employee
go |
执行结果
ID, Name, Address, Salary, Bonus
home\sql2008(HOME\MAK): (0 row(s) affected)
home\sql2008(HOME\MAK): (1 row(s) affected)
home\sql2008(HOME\MAK): (1 row(s) affected)
home\sql2008(HOME\MAK): (1 row(s) affected)
home\sql2008(HOME\MAK): (1 row(s) affected)
home\sql2008(HOME\MAK): (1 row(s) affected)
ID, Name, Address, Salary, Bonus
1, Dancing Doll, 221, West Broad st,
Greenbay, Wisconsin, 60000.0000, 1000.0000
2, Rainbow Dance, 21, East st,
Denville, New Jersey, 68000.0000, 1300.0000
3, Water Dance, 1, South Broad st,
Quincy, Massachusetts, 76000.0000, 1600.0000
4, Mickey Mouse, 5, Main,
Greenbay, Wisconsin, 120000.0000, 12000.0000
5, Rat year, 7, New road,
Danbury , Connecticut, 45000.0000, 1600.0000
home\sql2008(HOME\MAK): (5 row(s) affected) |
第七步
更新及删除
|