"use strict";(self.webpackChunkdocs_site=self.webpackChunkdocs_site||[]).push([[119],{4407:(e,n,r)=>{r.r(n),r.d(n,{assets:()=>i,contentTitle:()=>o,default:()=>u,frontMatter:()=>l,metadata:()=>t,toc:()=>c});const t=JSON.parse('{"id":"XXTLanControl.lua/tabledb/create","title":"Create A Table (LCC.db.create)","description":"Signature","source":"@site/i18n/en/docusaurus-plugin-content-docs/current/XXTLanControl.lua/tabledb/create.md","sourceDirName":"XXTLanControl.lua/tabledb","slug":"/XXTLanControl.lua/tabledb/create","permalink":"/docs/en/XXTLanControl.lua/tabledb/create","draft":false,"unlisted":false,"tags":[],"version":"current","sidebarPosition":20,"frontMatter":{"sidebar_position":20},"sidebar":"tutorialSidebar","previous":{"title":"TableDB Overview","permalink":"/docs/en/XXTLanControl.lua/tabledb/"},"next":{"title":"Batch Insert Rows (LCC.db.add)","permalink":"/docs/en/XXTLanControl.lua/tabledb/add"}}');var a=r(4848),s=r(8453);const l={sidebar_position:20},o="Create A Table (LCC.db.create)",i={},c=[{value:"Signature",id:"signature",level:2},{value:"Parameters",id:"parameters",level:2},{value:"Returns",id:"returns",level:2},{value:"Notes",id:"notes",level:2},{value:"Example",id:"example",level:2}];function d(e){const n={blockquote:"blockquote",br:"br",code:"code",h1:"h1",h2:"h2",header:"header",li:"li",p:"p",pre:"pre",ul:"ul",...(0,s.R)(),...e.components};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(n.header,{children:(0,a.jsx)(n.h1,{id:"create-a-table-lccdbcreate",children:"Create A Table (LCC.db.create)"})}),"\n",(0,a.jsx)(n.h2,{id:"signature",children:"Signature"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-lua",children:"ok, err = LCC.db.create(name, columns, timeout?)\n"})}),"\n",(0,a.jsx)(n.h2,{id:"parameters",children:"Parameters"}),"\n",(0,a.jsxs)(n.ul,{children:["\n",(0,a.jsxs)(n.li,{children:["name",(0,a.jsx)(n.br,{}),"\n","String. Table name. Must be non-empty and no longer than 256 bytes."]}),"\n",(0,a.jsxs)(n.li,{children:["columns",(0,a.jsx)(n.br,{}),"\n","Table. Array of column names. Each name must be non-empty valid UTF-8, must not repeat, and must not be ",(0,a.jsx)(n.code,{children:"id"}),"."]}),"\n",(0,a.jsxs)(n.li,{children:["timeout",(0,a.jsx)(n.br,{}),"\n","Number, optional. Request timeout in seconds, default ",(0,a.jsx)(n.code,{children:"60"}),"."]}),"\n"]}),"\n",(0,a.jsx)(n.h2,{id:"returns",children:"Returns"}),"\n",(0,a.jsxs)(n.ul,{children:["\n",(0,a.jsxs)(n.li,{children:["ok",(0,a.jsx)(n.br,{}),"\n","Boolean. ",(0,a.jsx)(n.code,{children:"true"})," on success, ",(0,a.jsx)(n.code,{children:"false"})," on failure."]}),"\n",(0,a.jsxs)(n.li,{children:["err",(0,a.jsx)(n.br,{}),"\n","String or ",(0,a.jsx)(n.code,{children:"nil"}),". Error message on failure; ",(0,a.jsx)(n.code,{children:"'table already exists'"})," when the table is present."]}),"\n"]}),"\n",(0,a.jsx)(n.h2,{id:"notes",children:"Notes"}),"\n",(0,a.jsxs)(n.blockquote,{children:["\n",(0,a.jsxs)(n.p,{children:["Creates a new table; every user column is stored as ",(0,a.jsx)(n.code,{children:"TEXT"}),", and an auto-increment ",(0,a.jsx)(n.code,{children:"id"})," is added automatically.",(0,a.jsx)(n.br,{}),"\n","Empty or oversized names and non-UTF-8 column names raise Lua parameter errors before the request is sent.",(0,a.jsx)(n.br,{}),"\n","Duplicate column names return an error."]}),"\n"]}),"\n",(0,a.jsx)(n.h2,{id:"example",children:"Example"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-lua",children:'local ok, err = LCC.db.create("tasks", {"Name", "Status", "Remark"})\nif not ok then\n    error(err)\nend\n'})})]})}function u(e={}){const{wrapper:n}={...(0,s.R)(),...e.components};return n?(0,a.jsx)(n,{...e,children:(0,a.jsx)(d,{...e})}):d(e)}},8453:(e,n,r)=>{r.d(n,{R:()=>l,x:()=>o});var t=r(6540);const a={},s=t.createContext(a);function l(e){const n=t.useContext(s);return t.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function o(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(a):e.components||a:l(e.components),t.createElement(s.Provider,{value:n},e.children)}}}]);