I am working on a program that issues DDL. I would like to know whether CREATE TABLE
and similar DDL can be rolled back in
Describe how each database handles transactions with DDL.
The CREATE TABLE statement in InnoDB is processed as a single transaction. This means that a ROLLBACK from the user does not undo CREATE TABLE statements the user made during that transaction.
Yes, it is possible to use many ALTER TABLE statements in one transaction with ROLLBACK and COMMIT .
Some statements cannot be rolled back. In general, these include data definition language (DDL) statements, such as those that create or drop databases, those that create, drop, or alter tables or stored routines.
The ROLLBACK command is the transactional command used to undo transactions that have not already been saved to the database. This command can only be used to undo transactions since the last COMMIT or ROLLBACK command was issued.
http://wiki.postgresql.org/wiki/Transactional_DDL_in_PostgreSQL:_A_Competitive_Analysis provides an overview of this issue from PostgreSQL's perspective.
Is DDL transactional according to this document?
SQLite also appears to have transactional DDL as well. I was able to ROLLBACK
a CREATE TABLE
statement in SQLite. Its CREATE TABLE
documentation does not mention any special transactional 'gotchas'.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With