Communiquez avec les autres et partagez vos connaissances professionnelles

Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.

Suivre

What is the difference between transaction and query?

user-image
Question ajoutée par Faten Almajaly
Date de publication: 2015/09/02
Emad Mohammed said abdalla
par Emad Mohammed said abdalla , ERP & IT Software, operation general manager . , AL DOHA Company

A query is a single SQL statement that does Select, Update, Insert or Delete of rows.A transaction is a consecutive sequence of SQL statements (from the application viewpoint) that have the "ACID" properties:

  • Atomicity: All statements or none are executed.
  • Consistency: Data integrity is always maintained.
  • Isolation: Transaction A can never affect Transaction B.
  • Durability: Changes that are committed by a transaction persist, even in event of system failure.

Abdessamed HACENE
par Abdessamed HACENE , J2EE Developper , ELIT SPA

Query is a single statement , 

Transaction is a set of queries that are all run or all rejected , if a query of transaction rejected , all other queries (of transaction) are rejected also

Mohammed Aamir Murthaza
par Mohammed Aamir Murthaza , Software Quality Assurance Engineer , Cognizant Technology and Solutions

 As we know, query is a single SQL statement that does Select, Update, Insert or Delete of rows. A transaction is a consecutive sequence of SQL statements (from the application viewpoint) that have the "ACID" properties: Atomicity: All statements or none are executed. Consistency: Data integrity is always maintained.

 

 

The query is simple set of insert,update,delete statement where as transaction is a set of statement which follows ACID properties.

Jay Joshi
par Jay Joshi , Database Developer , Accion Labs [Client: Amway]

Hello,

 

To give a very simple explanation on transaction and query:

Lets take an example where there are3 queries that execute and we execute these queries in2 different ways, With and Without Transaction.

Now when these queries are executed, assume that Query1 and2 is executed successfully, but Query3 fails, and we need to make sure that the data is committed to the database only if all three Queries are executed successfully.

Scenario1: when we execute the3 queries without a transaction, Query1 and2 will be executed successfully and Query3 fails to execute and so the data update only up to Query2 is committed to the database leaving it in an in-consistent state.

Scenario2: when we execute the3 queries with a transaction, Query1 and2 will be executed successfully and Query3 fails to execute and now the entire transaction will be rolled back leaving the data in the state as it was before Query1 was executed, and so the data is in a consistent state.

 

Hope this was useful to understand, if there are any queries / doubts, please let me know.

Thanks.

Mourhaf Alhalabi
par Mourhaf Alhalabi , Systems administrator / Agile / Scrum

A query is usually used to get data from a db, while the transaction can contain many queries and statements that all either success or fail, in other words a transaction either makes its all effects or does nothing e.g. money transfer between two accounts ( subtraction and addition) either together or none

erwin cailing
par erwin cailing , Security , Kuwait Airways Cargo

transactions more on either computers and written but query seems like talking

Sahada Sherin B
par Sahada Sherin B , ERP ANALYST , Silicon Pvt. Ltd

A query is a single sql statement that does either insert, update or delete certain attributes or rows.

A transaction is a group of statements, that obeys the ACID property. ACID stands for Atomicity, Consistency, Isolation, Durability.

Atomicity: these group of statements are considered to be single unit, either they have to be executed completely or none.

Consistency: The database should always be in a consistent state.

Isolation: Atransaction should not affect other transaction in any way.

Durability: Once a transaction is commited, its affects are permanent in the database.

 

Javed Khan
par Javed Khan , Technical Lead , MetricStream

A Query which is written to perform a task onset of records called query, not necessarily have to be made permanent in the database. 

 

The transaction we call anything between two DDL.

that means a transaction which ran between two DDL's and committed or reverted back.  

Sadik Shaik
par Sadik Shaik , IT Analyst , TATA CONSULTANCY SERVICES

Query is a single SQL statement and transaction is a set of SQL statements.

Adel Ezat Fawzy Ellozy
par Adel Ezat Fawzy Ellozy , Webdeveloper. , Saudi Arabian Maritiem Sports Federation

a query is a single SQL statement against database like(select , update , insert , delete ) .

 

A transaction is a single unit of work ( group of statements ).

If a transaction is successful, all of the data modifications made during the transaction are committed and become a permanent part of the database.

If a transaction encounters errors and must be canceled or rolled back, then all of the data modifications are erased.

Jason Morales
par Jason Morales , C#.net Programmer / Software Developer , Cebupacific Airline

A query is a single statement to manipulate data.(eg: SELECT, UPDATE, INSERT ,DELETE)

While a transaction is a series of statements which is defined by ACID.

Atomiticy - All statement will be executed or none

Consistency - Maintain Data integrity

Isolation - transaction A shall not affect transaction B

Durability - Able to persist data even if system failure occurs

More Questions Like This