code

데이터베이스 트랜잭션이란 무엇입니까?

codestyles 2020. 8. 24. 08:22
반응형

데이터베이스 트랜잭션이란 무엇입니까?


누군가 컴퓨팅에 적용되는 트랜잭션에 대해 (가능한 것보다 간단하지는 않지만) 간단한 설명을 제공 할 수 있습니까 (위키 백과에서 복사 한 경우라도)?


트랜잭션은 "전체"로 취급하려는 작업 단위입니다. 그것은 완전히 일어나거나 전혀 일어나지 않아야합니다.

전형적인 예는 한 은행 계좌에서 다른 계좌로 돈을 이체하는 것입니다. 그렇게하려면 먼저 소스 계정에서 금액을 인출 한 다음 대상 계정에 입금해야합니다. 작업이 완전히 성공해야합니다. 중간에 멈 추면 돈을 잃게되고 그것은 매우 나쁩니다.

현대 데이터베이스에서 트랜잭션은 다른 사람이 중간에 작성한 데이터에 액세스 할 수 없도록하는 등 다른 작업도 수행합니다. 그러나 기본 아이디어는 동일합니다. 어떤 일이 발생하더라도 작업하는 데이터가 합리적인 상태 에 있도록 보장하기 위해 트랜잭션이 존재합니다 . 그들은 돈이 한 계좌에서 인출되지만 다른 계좌로 입금되지 않는 상황이 없을 것임을 보장합니다.


트랜잭션은 상태 변경을 나타내는 방법입니다. 트랜잭션에는 일반적으로 ACID라고하는 네 가지 속성이 있습니다.

  • 원 자성 (변경 사항이 커밋 된 경우 한 번에 발생하며 "반 변경"을 볼 수 없음)
  • 일관성 (시스템의 새 상태가 유효한 경우에만 변경이 발생할 수 있습니다. 잘못된 변경을 커밋하려는 시도는 실패하고 시스템은 이전의 유효한 상태로 유지됩니다)
  • 격리 됨 (커밋 될 때까지 아무도 트랜잭션의 일부를 볼 수 없음)
  • 지속성 (변경이 발생하면 시스템이 트랜잭션이 커밋되었다고 말하면 클라이언트는 변경을 "고정"하기 위해 시스템을 "플러시"하는 것에 대해 걱정할 필요가 없습니다.)

자세한 내용은 Wikipedia ACID 항목을 참조하십시오.

일반적으로 데이터베이스에 적용되지만 반드시 그럴 필요는 없습니다. (특히 소프트웨어 트랜잭션 메모리를 참조하십시오 .)


여기에 간단한 설명이 있습니다. 계정 A에서 계정 B로 100 달러를 이체해야합니다. 다음 중 하나를 수행 할 수 있습니다.

accountA -= 100;
accountB += 100;

또는

accountB += 100;
accountA -= 100;

쌍의 첫 번째 작업과 두 번째 작업 사이에 문제가 발생하면 문제가 있습니다. 100 달러가 사라지거나 갑자기 나타났습니다.

트랜잭션은 작업 그룹을 표시하고 모두 실행 (커밋)하거나 시스템 상태가 전혀 실행되지 않은 것처럼 (롤백) 실행되는 방식으로 실행할 수있는 메커니즘입니다.

beginTransaction;
accountB += 100;
accountA -= 100;
commitTransaction;

100 달러를 이체하거나 두 계정을 모두 초기 상태로 둡니다.


"완전히 완료되거나 완전히 실패하여 데이터베이스를 일관된 상태로 유지해야하는 일련의 데이터 조작 명령문"


트랜잭션은 하나의 단위로 처리되는 하나 이상의 SQL 작업 시퀀스입니다.

특히 각 트랜잭션은 격리 된 상태로 실행되는 것으로 보이며 시스템이 실패하면 각 트랜잭션이 전체적으로 실행되거나 전부 실행되지는 않습니다.

거래의 개념은 완전히 독립적 인 두 가지 관심사에 의해 동기가 부여됩니다. 하나는 여러 클라이언트가 데이터베이스에 동시에 액세스하는 것과 관련이 있고 다른 하나는 시스템 장애에 대해 탄력적 인 시스템을 갖는 것과 관련이 있습니다.

트랜잭션은 ACID 속성으로 알려진 것을 지원합니다.

  • A : 원 자성;
  • C : 일관성;
  • I : 격리;
  • D : 내구성.

http://en.wikipedia.org/wiki/Database_transaction
http://en.wikipedia.org/wiki/ACID
ACID = tomicity, C의 onsistency, I의 solation, D의 가능성에 의한

여러 트랜잭션 리소스가 단일 트랜잭션에 포함되도록하려면 2 단계 커밋 솔루션 과 같은 것을 사용해야 합니다. XA 는 매우 광범위하게 지원됩니다.


나는 '트랜잭션 처리'의 정의가 컴퓨터 과학의 개념으로 트랜잭션을 다루기 때문에 더 유용 할 것이라고 제안합니다.

wikipedia에서 :

컴퓨터 과학에서 트랜잭션 처리는 트랜잭션이라고하는 개별적이고 분할 할 수없는 작업으로 구분되는 정보 처리입니다. 각 트랜잭션은 완전한 단위로 성공하거나 실패해야합니다. 중간 상태로 남아있을 수 없습니다.

http://en.wikipedia.org/wiki/Transaction_processing#Implementations


In addition to the above responses, it should be noted that there is, at least in theory, no restriction whatsoever as to what kind of resources are involved in a transaction.

Most of the time, it is just a database, or multiple distinct databases, but it is also conceivable that a printer takes part in a transaction, and can cause that transaction to fail, say in the event of a paper jam.


Transaction can be defined as a collection of task that are considered as minimum processing unit. Each minimum processing unit can not be divided further.

The main operation of a transaction are read and write.

All transaction must contain four properties that commonly known as ACID properties for the purpose of ensuring accuracy , completeness and data integrity.


I think a transaction is an atomic action in terms of DBMS.

that means it cannot be seperated. yes, in a transction, there may be several instructions for the system to execute. but they are binded together to finished a single basic task.

for example. you need to walk through a bridge (let's treat this as a transction), and to do this, say, you need 100 steps. overall, these steps cannot be seperated. when you've done half of them, there is only two choice for you: continue to finish them all, and go back to the start point. it's just like the to result of a transaction: success( committed ) and fail( rollback )


Transaction is an indivisible unit of data processing -All transactions must have the ACID properties:

ie:Atomicity,Consistency,Isolation and Durable Transaction is all or nothing but not intermidiate (it means if you transfer your money from one account to another account,one account have to lose that much and other one have to gain that amount,but if you transfer money from one account and another account is still empty that will be not a transaction)

참고URL : https://stackoverflow.com/questions/974596/what-is-a-database-transaction

반응형