A query usually refers to a SELECT statement, but may also refer to data modifications as well -- UPDATE, INSERT, DELETE, and MERGE are common DML ("data modification language") statements. Personally, I would call these four operations DML statements and reserve query for SELECT statements; I find this a useful distinction.
쿼리란 평소에는 SELECT statement를 말하지만, 데이타를 수정하는 UPDATE, INSERT, DELETE, 그리고 MERGE 즉, DML(data modification language)에 적용 되기도 합니다.
Databases implement a set of properties called ACID properties. These basically say that any SQL statement sees consistent data, regardless of what else is going on in the database.
A simple way to think of about these is that all operations are serialized -- one statement completes before another begins, even in a multi-user environment. Serialization guarantees that operations are isolated from each other. In practice, serialization is very expensive and databases have other mechanisms to ensure integrity, but it is a useful abstraction when learning about the concepts.
What are transactions? Transactions are the mechanism that databases use to ensure the integrity of the data when data is being modified. Transactions often consist of one statement that modifies the data. But that is not necessary. In fact, you can have a complex set of data transformations within a single transaction.
transaction이란 무엇일까요? Transactions은 데이타베이스가 사용 하는 메카니즘으로 데이터가 수정이 될때 데이타의 무결성을 보장하는 메카니즘으로 볼수있습니다. Transactions은 종종 하나의 statement로 db 데이터를 수정하지만 항상 그렇다고 할수도 없습니다. 사실, 하나의 transaction으로 복잡한 데이타 변화를 줄수도 있습니다.
The three key operations on a transactions are:
- BEGIN TRANSACTION: Tell the database that a transaction is beginning. All changes within the transaction are invisible to other users while the transaction is "active".
- COMMIT TRANSACTION: Make all the changes visible in the database. Conceptually, this happens instantaneously. The database guarantees that other users will not see partial changes to the data (i.e. enforces data integrity).
- ROLLBACK TRANSACTION: Undo all the work. No other users ever see the changes.
Note: Many databases have options to weaken the data integrity. These can be useful for performance reasons for users who know what they are doing.
I should note that if all operations on a database are SELECT statements, then transactions are not necessary. The data is not changing, so the view of the data is consistent. So transactions are generally associated with DML statements.
Transaction은 보편적으로 DML statements와 연관됩니다.
Working with SQL DBs you got both - transactions and queries. Here a simple explanation:
SQl db를 사용 하면 쿼리와 transaction, 이 두가지를 이용할수 있습니다.
Queries are operations to CRUD (create (insert), update (set), read (select), delete (delete)) data inside a table.
The transaction is more or less the process of a single or multiple statements/queries/operations getting executed.
So this means a transaction contains some interactions and a query is an example of 1 kind of interaction. Important to know is that transactions are like buying stuff online. You operate and mark things you want to buy but only if you click "buy" you will finally get and pay for the stuff. For transactions, that means they need to be committed afterwards otherwise it will be undone again (rollback). Mostly your frameworks will commit changes automatically after each interaction and end the transaction with it.
쿼리는 CRUD(create(insert), read(select), update(set), delete(delete) 기능들을 db안에서 수행합니다.
Transaction은 하나 혹은 여러개의 쿼리/statements/operations 실행하는 작업이라 말할수 있습니다. - 그 뜻은 transaction이 여러 db와 여러 상호작용들(예:특정 데이타들을 선택, 그후 데이타 수정)을 가질수 있는데 여기서 하나의 쿼리는 그 상호작용중 하나를 말할수 있습니다.
아래 스텍오버플로우에서 발췌 하고 개인적으로 부분 해석을 하였습니다.
https://stackoverflow.com/questions/67224866/what-is-the-difference-between-a-query-and-transaction-in-sql