我们可以在tranasction(rollback,commit)中执行ddl命令吗? [英] Can we execute ddl command in tranasction(rollback, commit) ?

查看:84
本文介绍了我们可以在tranasction(rollback,commit)中执行ddl命令吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个疑问我需要明确的答案是或否我们是否可以在交易中使用ddl命令?



再一次



我们是否可以在函数中执行dml语句请回复此问题。



我尝试过:



开始转换

trucate table emp

rollback

I have one doubt i need clear cut answer yes or no whether we can use ddl command in transaction or not?

one more

whether we can execute dml statments in function please anser this quetion.

What I have tried:

begin trans
trucate table emp
rollback

推荐答案

我不太确定其他DBMS所以我会在答案中关注SQL Server。



我可以使用DDL吗?交易?

,但并非所有人都被允许!请参阅文档 [ ^ ]获取完整的语句列表在交易中不允许。正如您已经发现的那样,TRUNCATE可以回滚得很好。



我可以在函数中使用DDL吗?

。您甚至不允许在函数中执行插入或删除操作。请参阅文档此处 [ ^ ]或 here [ ^ ]了解更多信息。
I'm no so certain about other DBMS so I will focus on SQL Server in my answer.

Can I use DDL in a transaction?
YES, but not all are allowed! Please see the documentation[^] for a complete list of statements that are not allowed in transactions. As you already found out TRUNCATE can be rolled back just fine.

Can I use DDL in a functions?
NO. You are not even allowed to perform inserts or deletes in a function. Please refer to documentation here[^] or here[^] for more information.


这篇关于我们可以在tranasction(rollback,commit)中执行ddl命令吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆