0

Which one of the following commands will NOT end a transaction?

  • COMMIT
  • CREATE
  • ALTER
  • DELETE

I personally think that COMMIT is the only command that will end a transaction. which leaves other options as the answer to the question.

The question only asks for 1 choice. I did search the web and I understand what transactions are in SQL and how you start one, write the appropriate query... and when you are sure that you got it right then you do COMMIT to end the transaction.

what am I missing here?

edit : The question does not provide any clarifications. That is essentially the entire question. I have no additional clarification I could provide.

Mish Akopyan
  • 27
  • 1
  • 5
  • 1
    Could you please clarify "end a transaction"? You could either `COMMIT` or `ROLLBACK` a transaction. – Illya Kysil Nov 17 '18 at 22:58
  • This is the issue with the question. it does not provide any clarifications. That is essentially the entire question. I am not sure how to interpret it either. – Mish Akopyan Nov 17 '18 at 23:01
  • Its very easy to find out: Open 2 tabs in a query editor. In tab1 Start a transaction and then issue one of the those statements. In tab1 write a query and see if the transaction has been committed. For example, for DELETE, select a specific record in tab1. Start a transaction in tab2 and delete the record without committing the transaction. Go back to tab1 and see if the record is still there. If yes, DELETE does not end the transaction. Do the same for the other ones. – CodingYoshi Nov 17 '18 at 23:07
  • 1
    @codingyoshi reading https://stackoverflow.com/questions/4692690/is-it-possible-to-roll-back-create-table-and-alter-table-statements-in-major-sql might be easier – Caius Jard Nov 17 '18 at 23:10

3 Answers3

1

You didn't specify a database vendor. Some database systems implicitly commit transactions when DDL statements like CREATE and ALTER are executed, others can roll the DDL into the transaction (so rolling back the tran also rolls back the table creation etc)

DELETE is the only one that you could reasonably assert doesn't end a transaction across most world databases (it'd make for a poor transaction engine if deleting data ended a transaction)

Caius Jard
  • 72,509
  • 5
  • 49
  • 80
  • I see. thanks for the response. This is the issue with the question. it does not provide any clarifications or what kind of database vendor it is using. That is essentially the entire question. – Mish Akopyan Nov 17 '18 at 23:08
  • Then go for DELETE if it's a single choice question, for the reasons mentioned – Caius Jard Nov 17 '18 at 23:09
0

The correct answer is: [select] statement/command would not cause a transaction to end

(I got this answer but there is no explanation)

0

If you are talking about oracle, DDL commands are by default auto-commit. So one option that you can safely choose is DELETE. CREATE and ALTER are DDL. COMMIT is TCL and is used to permanently save the changes made and ends the transaction after that.