Skip to content

ACID

一句话解释

ACID stands for Atomicity, Consistency, Isolation, and Durability — four 属性那个 guarantee reliable 数据库事务.

用大白话说

ACID is an acronym for the four properties that make database transactions reliable:

  • Atomicity: The transaction is all-or-nothing. Either every operation succeeds, or none do. If one fails, the whole transaction is rolled back.
  • Consistency: The transaction moves the database from one valid state to another. All constraints (foreign keys, unique keys, etc.) must be satisfied after the transaction.
  • Isolation: Concurrent transactions do not interfere with each other. Each transaction appears to run as if it were the only one, even if many are running simultaneously.
  • Durability: Once a transaction is committed, the changes are permanent — they survive crashes, power failures, and restarts.

Relational databases typically provide full ACID guarantees. Some NoSQL databases relax these (especially Isolation and Consistency) for better performance and scale — this is the CAP theorem trade-off.

示例

sql
-- A transaction that must be ACID-compliant
BEGIN;
UPDATE accounts SET balance = balance - 500 WHERE id = 1;
UPDATE accounts SET balance = balance + 500 WHERE id = 2;
-- Consistency check: total money is unchanged
COMMIT;

Atomicity: 两者都更新 or neither. Consistency: 总计 balance 是 preserved. Isolation: other 事务 see transfer as 瞬时. Durability: 一次 committed, transfer 是 permanent.

相关术语

相关资源

相关课程

解读错误信息

用大白话解释常见错误——什么意思、为什么发生、如何修复。

查看错误

← 返回术语表