{"title":"Views","description":"Create, store, and query SQL views in Altertable catalog metadata so teams can reuse governed lakehouse logic.","order":640,"navigation":true,"body":{"code":"var Component=(()=>{var w=Object.create;var o=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var g=Object.getPrototypeOf,v=Object.prototype.hasOwnProperty;var f=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),y=(t,e)=>{for(var r in e)o(t,r,{get:e[r],enumerable:!0})},s=(t,e,r,a)=>{if(e&&typeof e==\"object\"||typeof e==\"function\")for(let i of p(e))!v.call(t,i)&&i!==r&&o(t,i,{get:()=>e[i],enumerable:!(a=m(e,i))||a.enumerable});return t};var b=(t,e,r)=>(r=t!=null?w(g(t)):{},s(e||!t||!t.__esModule?o(r,\"default\",{value:t,enumerable:!0}):r,t)),x=t=>s(o({},\"__esModule\",{value:!0}),t);var l=f((q,c)=>{c.exports=_jsx_runtime});var E={};y(E,{default:()=>u,frontmatter:()=>_});var n=b(l()),_={title:\"Views\",description:\"Create, store, and query SQL views in Altertable catalog metadata so teams can reuse governed lakehouse logic.\",order:640};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:r,DocsPreviewSection:a}=e;return r||h(\"DocsPreviewDocument\",!0),a||h(\"DocsPreviewSection\",!0),(0,n.jsxs)(r,{anchors:\"views create-a-view drop-a-view when-to-use-views learn-more\",children:[(0,n.jsxs)(a,{sectionId:\"views\",sectionTitle:\"Views\",anchors:\"\",ancestors:\"\",index:\"0\",children:[(0,n.jsx)(e.h1,{id:\"views\",children:\"Views\"}),`\n`,(0,n.jsxs)(e.p,{children:[\"Altertable catalog views are defined with standard \",(0,n.jsx)(e.code,{children:\"CREATE VIEW\"}),\" syntax and stored in catalog metadata. They provide a stable name over a query so dashboards, agents, and downstream SQL can reference a logical table without repeating the underlying statement.\"]}),`\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)(a,{sectionId:\"create-a-view\",sectionTitle:\"Create a view\",anchors:\"\",ancestors:\"\",index:\"1\",children:[(0,n.jsx)(e.h2,{id:\"create-a-view\",children:\"Create a view\"}),`\n`,(0,n.jsx)(e.pre,{children:(0,n.jsx)(e.code,{className:\"language-sql\",children:`CREATE VIEW my_catalog.main.open_purchase_orders AS\nSELECT po_id, vendor_id, amount, submitted_at\nFROM my_catalog.main.purchase_orders\nWHERE status IN ('draft', 'submitted');\n`})}),`\n`,(0,n.jsx)(e.p,{children:\"Views can reference other views and tables in the same catalog. Altertable resolves the view definition at query time using the current catalog state.\"}),`\n`]}),(0,n.jsxs)(a,{sectionId:\"drop-a-view\",sectionTitle:\"Drop a view\",anchors:\"\",ancestors:\"\",index:\"2\",children:[(0,n.jsx)(e.h2,{id:\"drop-a-view\",children:\"Drop a view\"}),`\n`,(0,n.jsx)(e.pre,{children:(0,n.jsx)(e.code,{className:\"language-sql\",children:`DROP VIEW my_catalog.main.open_purchase_orders;\n`})}),`\n`]}),(0,n.jsxs)(a,{sectionId:\"when-to-use-views\",sectionTitle:\"When to use views\",anchors:\"\",ancestors:\"\",index:\"3\",children:[(0,n.jsx)(e.h2,{id:\"when-to-use-views\",children:\"When to use views\"}),`\n`,(0,n.jsx)(e.p,{children:\"Use views to encapsulate common filters, joins, or column projections that many queries share. They keep consumer SQL stable when underlying table layouts evolve, as long as the view definition is updated to preserve the expected columns.\"}),`\n`,(0,n.jsx)(e.p,{children:\"Views do not store data \\u2014 they are query definitions only. For materialized results that persist between queries, write to a table instead.\"}),`\n`]}),(0,n.jsxs)(a,{sectionId:\"learn-more\",sectionTitle:\"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\",children:\"Altertable Catalogs\"})}),\": Catalogs for storing and querying your data\"]}),`\n`,(0,n.jsxs)(e.li,{children:[(0,n.jsx)(e.strong,{children:(0,n.jsx)(e.a,{href:\"/docs/lakehouse/features/macros\",children:\"Macros\"})}),\": Reusable scalar and table expressions\"]}),`\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 x(E);})();\n;return Component;"},"_id":"docs/lakehouse/features/views.mdx","_raw":{"sourceFilePath":"docs/lakehouse/features/views.mdx","sourceFileName":"views.mdx","sourceFileDir":"docs/lakehouse/features","contentType":"mdx","flattenedPath":"docs/lakehouse/features/views"},"type":"Docs","path":"/lakehouse/features/views","level":3,"parent":"lakehouse/features"}