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

OUTPUT 在isnert delete update 的神奇功效

PHPz
Release: 2019-02-26 17:27:19
Original
2668 people have browsed it

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

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

使用例子:

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

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

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

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

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

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


Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template