Redo Logs in Database Systems

用 ChatGPT 查了下 redo log 是怎麼用在 database crash or power loss 後的 recovery 裡,這邊做個小筆記統整一下:

  • 進行交易時,會依序進行以下步驟:
    1. 寫 redo log, 裡面記錄準備要做的改變,並記錄這個 transaction 的狀態為 in progress
    2. 把 redo log 紀錄的那些改變實際寫入 database files
    3. 把 redo log 的 transaction 狀態改為 committed
    4. 回傳 OK

PostgreSQL/MySQL local docker 開發的初始 setup

container run 起來之後:
PostgreSQL:

  1. docker exec -it {db-container-name} psql -U postgres
    • 以預設 user postgres 連進 DB
  2. create user {username} with password '{password}';
  3. create database {database_name} with owner {username};
Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×