Home  >  Article  >  Database  >  OUTPUT 在isnert delete update 的神奇功效

OUTPUT 在isnert delete update 的神奇功效

PHPz
PHPzOriginal
2016-05-27 19:11:442638browse

 Inserted   deleted  个人理解 应该是两个 临时表   分别存储 变动后的数据集  和  变动前的数据集

相关mysql视频教程推荐:《mysql教程

使用例子:

1.对于INSERT,可以引用inserted表以查询新行的属性. 

insert into [表名] (a) OUTPUT Inserted.a values ('a')

2.对于DELETE,可以引用deleted表以查询旧行的属性. 

delete [表名] OUTPUT deleted.a where links = 'a'

3.对于UPDATE,使用deleted表查询被更新行在更改前的属性,用inserted表标识被更新行在更改后的值. 

update [表名] set a = 'b' OUTPUT Inserted.a where a = 'a'(返回修改后的值) 
update [表名] set a = 'b' OUTPUT deleted.a where a = 'a' (返回修改前的值)


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn