Is it possible to run multiple DDL statements inside a transaction (within SQL Server)?

后端 未结 4 564
南旧
南旧 2020-11-28 15:41

I\'m wondering if it is possible to run multiple DDL statements inside a transaction. I\'m specially interested on SQL Server, even though answers with other databases (Orac

4条回答
  •  日久生厌
    2020-11-28 16:21

    I know most databases have restrictions, but Postgres doesn't. You can run any number table creations, column changes and index changes in a transaction, and the changes aren't visible to other users unit COMMIT succeeds. That's how databases should be! :-)

    As for SQL Server you can run DDL inside of a transaction, but SQL Server does not version metadata, and so changes would be visible to others before the transaction commits. But some DDL statements can be rolled back if you are in a transaction, but for which ones work and which ones don't you'll need to run some tests.

提交回复
热议问题