{"title":"Transactions","description":"Run ACID transactions against Altertable catalogs with snapshot isolation and all-or-nothing semantics.","order":620,"navigation":true,"body":{"code":"var Component=(()=>{var p=Object.create;var o=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var f=Object.getPrototypeOf,w=Object.prototype.hasOwnProperty;var x=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),b=(t,e)=>{for(var a in e)o(t,a,{get:e[a],enumerable:!0})},c=(t,e,a,r)=>{if(e&&typeof e==\"object\"||typeof e==\"function\")for(let s of g(e))!w.call(t,s)&&s!==a&&o(t,s,{get:()=>e[s],enumerable:!(r=m(e,s))||r.enumerable});return t};var A=(t,e,a)=>(a=t!=null?p(f(t)):{},c(e||!t||!t.__esModule?o(a,\"default\",{value:t,enumerable:!0}):a,t)),y=t=>c(o({},\"__esModule\",{value:!0}),t);var l=x((v,i)=>{i.exports=_jsx_runtime});var T={};b(T,{default:()=>u,frontmatter:()=>E});var n=A(l()),E={title:\"Transactions\",description:\"Run ACID transactions against Altertable catalogs with snapshot isolation and all-or-nothing semantics.\",order:620};function d(t){let e={a:\"a\",code:\"code\",h1:\"h1\",h2:\"h2\",li:\"li\",p:\"p\",pre:\"pre\",strong:\"strong\",ul:\"ul\",...t.components},{DocsPreviewDocument:a,DocsPreviewSection:r}=e;return a||h(\"DocsPreviewDocument\",!0),r||h(\"DocsPreviewSection\",!0),(0,n.jsxs)(a,{anchors:\"transactions basic-transaction-syntax snapshots concurrent-writes learn-more\",children:[(0,n.jsxs)(r,{sectionId:\"transactions\",anchors:\"\",ancestors:\"\",index:\"0\",children:[(0,n.jsx)(e.h1,{id:\"transactions\",children:\"Transactions\"}),`\n`,(0,n.jsxs)(e.p,{children:[\"Altertable catalogs provide full ACID support with snapshot isolation for all reads and writes. Every operation \\u2014 including DDL statements such as \",(0,n.jsx)(e.code,{children:\"CREATE TABLE\"}),\" or \",(0,n.jsx)(e.code,{children:\"ALTER TABLE\"}),\" \\u2014 runs inside a transaction with all-or-nothing semantics. A transaction can compose multiple changes that succeed or fail together.\"]}),`\n`,(0,n.jsxs)(e.p,{children:[\"Run the statements below through Altertable's \",(0,n.jsx)(e.a,{href:\"/docs/lakehouse/sql-engine\",children:\"SQL engine\"}),\" against an \",(0,n.jsx)(e.a,{href:\"/docs/lakehouse/catalogs\",children:\"Altertable catalog\"}),\" you own.\"]}),`\n`]}),(0,n.jsxs)(r,{sectionId:\"basic-transaction-syntax\",anchors:\"\",ancestors:\"\",index:\"1\",children:[(0,n.jsx)(e.h2,{id:\"basic-transaction-syntax\",children:\"Basic transaction syntax\"}),`\n`,(0,n.jsx)(e.p,{children:\"Start a transaction, apply changes, then commit or roll back:\"}),`\n`,(0,n.jsx)(e.pre,{children:(0,n.jsx)(e.code,{className:\"language-sql\",children:`BEGIN TRANSACTION;\n\nINSERT INTO my_catalog.main.purchase_orders (po_id, status, amount)\nVALUES ('PO-8821', 'draft', 4200.00);\n\nUPDATE my_catalog.main.purchase_orders\nSET status = 'approved'\nWHERE po_id = 'PO-8821';\n\nCOMMIT;\n`})}),`\n`,(0,n.jsx)(e.p,{children:\"To discard uncommitted work:\"}),`\n`,(0,n.jsx)(e.pre,{children:(0,n.jsx)(e.code,{className:\"language-sql\",children:`ROLLBACK;\n`})}),`\n`,(0,n.jsxs)(e.p,{children:[(0,n.jsx)(e.code,{children:\"ABORT\"}),\" has the same behavior as \",(0,n.jsx)(e.code,{children:\"ROLLBACK\"}),\".\"]}),`\n`]}),(0,n.jsxs)(r,{sectionId:\"snapshots\",anchors:\"\",ancestors:\"\",index:\"2\",children:[(0,n.jsx)(e.h2,{id:\"snapshots\",children:\"Snapshots\"}),`\n`,(0,n.jsxs)(e.p,{children:[\"Each committed transaction \\u2014 a \",(0,n.jsx)(e.code,{children:\"BEGIN\"}),\" \\u2026 \",(0,n.jsx)(e.code,{children:\"COMMIT\"}),\" block \\u2014 creates one catalog snapshot. Snapshots power \",(0,n.jsx)(e.a,{href:\"/docs/lakehouse/features/time-travel\",children:\"time travel\"}),\" and the \",(0,n.jsx)(e.a,{href:\"/docs/lakehouse/features/data-change-feed\",children:\"data change feed\"}),\".\"]}),`\n`,(0,n.jsx)(e.p,{children:\"Use transactions when you need a consistent point-in-time view across multiple statements, or when a batch of writes must land atomically.\"}),`\n`]}),(0,n.jsxs)(r,{sectionId:\"concurrent-writes\",anchors:\"\",ancestors:\"\",index:\"3\",children:[(0,n.jsx)(e.h2,{id:\"concurrent-writes\",children:\"Concurrent writes\"}),`\n`,(0,n.jsx)(e.p,{children:\"When multiple transactions modify the same table concurrently, Altertable applies a default retry mechanism for conflicting writes.\"}),`\n`,(0,n.jsx)(e.p,{children:\"For long-running batches, keep transactions as short as practical to reduce contention and snapshot buildup.\"}),`\n`]}),(0,n.jsxs)(r,{sectionId:\"learn-more\",anchors:\"\",ancestors:\"\",index:\"4\",children:[(0,n.jsx)(e.h2,{id:\"learn-more\",children:\"Learn more\"}),`\n`,(0,n.jsxs)(e.ul,{children:[`\n`,(0,n.jsxs)(e.li,{children:[(0,n.jsx)(e.strong,{children:(0,n.jsx)(e.a,{href:\"/docs/lakehouse/features/time-travel\",children:\"Time Travel\"})}),\": Query historical snapshots and configure retention\"]}),`\n`,(0,n.jsxs)(e.li,{children:[(0,n.jsx)(e.strong,{children:(0,n.jsx)(e.a,{href:\"/docs/lakehouse/features/data-change-feed\",children:\"Data Change Feed\"})}),\": Read inserts, updates, and deletes between snapshots\"]}),`\n`,(0,n.jsxs)(e.li,{children:[(0,n.jsx)(e.strong,{children:(0,n.jsx)(e.a,{href:\"/docs/lakehouse/sql-engine\",children:\"SQL Engine\"})}),\": DuckDB dialect and federated queries\"]}),`\n`]})]})]})}function u(t={}){let{wrapper:e}=t.components||{};return e?(0,n.jsx)(e,{...t,children:(0,n.jsx)(d,{...t})}):d(t)}function h(t,e){throw new Error(\"Expected \"+(e?\"component\":\"object\")+\" `\"+t+\"` to be defined: you likely forgot to import, pass, or provide it.\")}return y(T);})();\n;return Component;"},"_id":"docs/lakehouse/features/transactions.mdx","_raw":{"sourceFilePath":"docs/lakehouse/features/transactions.mdx","sourceFileName":"transactions.mdx","sourceFileDir":"docs/lakehouse/features","contentType":"mdx","flattenedPath":"docs/lakehouse/features/transactions"},"type":"Docs","path":"/lakehouse/features/transactions","level":3,"parent":"lakehouse/features"}