blob: 457ef81fa14892b83429dc938c1e50583d8425f5 [file] [log] [blame]
<!doctype html><html itemscope itemtype=http://schema.org/WebPage lang=en class=no-js><head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name=robots content="index, follow"><link rel="shortcut icon" href=/favicons/favicon.ico><link rel=apple-touch-icon href=/favicons/apple-touch-icon-180x180.png sizes=180x180><link rel=icon type=image/png href=/favicons/favicon-16x16.png sizes=16x16><link rel=icon type=image/png href=/favicons/favicon-32x32.png sizes=32x32><link rel=icon type=image/png href=/favicons/android-36x36.png sizes=36x36><link rel=icon type=image/png href=/favicons/android-48x48.png sizes=48x48><link rel=icon type=image/png href=/favicons/android-72x72.png sizes=72x72><link rel=icon type=image/png href=/favicons/android-96x96.png sizes=96x96><link rel=icon type=image/png href=/favicons/android-144x144.png sizes=144x144><link rel=icon type=image/png href=/favicons/android-192x192.png sizes=192x192><title>CREATE TABLE | Apache HoraeDB</title>
<meta name=description content="Basic syntax Basic syntax:
1 2 3 4 5 CREATE TABLE [IF NOT EXISTS] table_name ( column_definitions ) [partition_options] ENGINE = engine_type [WITH ( table_options )]; Column definition syntax:
1 column_name column_type [[NOT] NULL] [TAG | TIMESTAMP KEY | PRIMARY KEY] [DICTIONARY] [COMMENT ''] Partition options syntax:"><meta property="og:url" content="https://horaedb.apache.org/docs/user-guide/sql/ddl/create_table/"><meta property="og:site_name" content="Apache HoraeDB"><meta property="og:title" content="CREATE TABLE"><meta property="og:description" content="Basic syntax Basic syntax:
1 2 3 4 5 CREATE TABLE [IF NOT EXISTS] table_name ( column_definitions ) [partition_options] ENGINE = engine_type [WITH ( table_options )]; Column definition syntax:
1 column_name column_type [[NOT] NULL] [TAG | TIMESTAMP KEY | PRIMARY KEY] [DICTIONARY] [COMMENT ''] Partition options syntax:"><meta property="og:locale" content="en"><meta property="og:type" content="article"><meta property="article:section" content="docs"><meta property="article:modified_time" content="2024-08-21T10:34:40+08:00"><meta itemprop=name content="CREATE TABLE"><meta itemprop=description content="Basic syntax Basic syntax:
1 2 3 4 5 CREATE TABLE [IF NOT EXISTS] table_name ( column_definitions ) [partition_options] ENGINE = engine_type [WITH ( table_options )]; Column definition syntax:
1 column_name column_type [[NOT] NULL] [TAG | TIMESTAMP KEY | PRIMARY KEY] [DICTIONARY] [COMMENT ''] Partition options syntax:"><meta itemprop=dateModified content="2024-08-21T10:34:40+08:00"><meta itemprop=wordCount content="283"><meta name=twitter:card content="summary"><meta name=twitter:title content="CREATE TABLE"><meta name=twitter:description content="Basic syntax Basic syntax:
1 2 3 4 5 CREATE TABLE [IF NOT EXISTS] table_name ( column_definitions ) [partition_options] ENGINE = engine_type [WITH ( table_options )]; Column definition syntax:
1 column_name column_type [[NOT] NULL] [TAG | TIMESTAMP KEY | PRIMARY KEY] [DICTIONARY] [COMMENT ''] Partition options syntax:"><link rel=preload href=/scss/main.min.5e43f8574351718e9b44966c9f3a571202ed048c082f457fb574c10b1a1bc56c.css as=style integrity="sha256-XkP4V0NRcY6bRJZsnzpXEgLtBIwIL0V/tXTBCxobxWw=" crossorigin=anonymous><link href=/scss/main.min.5e43f8574351718e9b44966c9f3a571202ed048c082f457fb574c10b1a1bc56c.css rel=stylesheet integrity="sha256-XkP4V0NRcY6bRJZsnzpXEgLtBIwIL0V/tXTBCxobxWw=" crossorigin=anonymous><script src=https://code.jquery.com/jquery-3.7.1.min.js integrity="sha512-v2CJ7UaYy4JwqLDIrZUI/4hqeoQieOmAZNXBeQyjo21dadnwR+8ZaIJVT8EE2iyI61OV8e6M8PP2/4hpQINQ/g==" crossorigin=anonymous></script><script defer src=https://unpkg.com/lunr@2.3.9/lunr.min.js integrity=sha384-203J0SNzyqHby3iU6hzvzltrWi/M41wOP5Gu+BiJMz5nwKykbkUx8Kp7iti0Lpli crossorigin=anonymous></script></head><body class=td-page><header><nav class="td-navbar js-navbar-scroll" data-bs-theme=dark><div class="container-fluid flex-column flex-md-row"><a class=navbar-brand href=/><span class="navbar-brand__logo navbar-logo"></span><span class=navbar-brand__name>Apache HoraeDB</span></a><div class="td-navbar-nav-scroll ms-md-auto" id=main_navbar><ul class=navbar-nav><li class=nav-item><a class="nav-link active" href=/docs/><i class='fa-solid fa-book'></i><span>Docs</span></a></li><li class=nav-item><a class=nav-link href=/blog/><i class='fa-brands fa-blogger'></i><span>Blog</span></a></li><li class=nav-item><a class=nav-link href=/downloads/><i class='fa-solid fa-download'></i><span>Downloads</span></a></li><li class=nav-item><a class=nav-link href=/community/><span>Community</span></a></li><li class="nav-item dropdown d-none d-lg-block"><div class=dropdown><a class="nav-link dropdown-toggle" href=# role=button data-bs-toggle=dropdown aria-haspopup=true aria-expanded=false>English</a><ul class=dropdown-menu><li><a class=dropdown-item href=/cn/docs/user-guide/sql/ddl/create_table/>中文</a></li></ul></div></li><li class="td-light-dark-menu nav-item dropdown"><svg class="d-none"><symbol id="check2" viewBox="0 0 16 16"><path d="M13.854 3.646a.5.5.0 010 .708l-7 7a.5.5.0 01-.708.0l-3.5-3.5a.5.5.0 11.708-.708L6.5 10.293l6.646-6.647a.5.5.0 01.708.0z"/></symbol><symbol id="circle-half" viewBox="0 0 16 16"><path d="M8 15A7 7 0 108 1v14zm0 1A8 8 0 118 0a8 8 0 010 16z"/></symbol><symbol id="moon-stars-fill" viewBox="0 0 16 16"><path d="M6 .278a.768.768.0 01.08.858 7.208 7.208.0 00-.878 3.46c0 4.021 3.278 7.277 7.318 7.277.527.0 1.04-.055 1.533-.16a.787.787.0 01.81.316.733.733.0 01-.031.893A8.349 8.349.0 018.344 16C3.734 16 0 12.286.0 7.71.0 4.266 2.114 1.312 5.124.06A.752.752.0 016 .278z"/><path d="M10.794 3.148a.217.217.0 01.412.0l.387 1.162c.173.518.579.924 1.097 1.097l1.162.387a.217.217.0 010 .412l-1.162.387A1.734 1.734.0 0011.593 7.69l-.387 1.162a.217.217.0 01-.412.0l-.387-1.162A1.734 1.734.0 009.31 6.593l-1.162-.387a.217.217.0 010-.412l1.162-.387a1.734 1.734.0 001.097-1.097l.387-1.162zM13.863.099a.145.145.0 01.274.0l.258.774c.115.346.386.617.732.732l.774.258a.145.145.0 010 .274l-.774.258a1.156 1.156.0 00-.732.732l-.258.774a.145.145.0 01-.274.0l-.258-.774a1.156 1.156.0 00-.732-.732l-.774-.258a.145.145.0 010-.274l.774-.258c.346-.115.617-.386.732-.732L13.863.1z"/></symbol><symbol id="sun-fill" viewBox="0 0 16 16"><path d="M8 12a4 4 0 100-8 4 4 0 000 8zM8 0a.5.5.0 01.5.5v2a.5.5.0 01-1 0v-2A.5.5.0 018 0zm0 13a.5.5.0 01.5.5v2a.5.5.0 01-1 0v-2A.5.5.0 018 13zm8-5a.5.5.0 01-.5.5h-2a.5.5.0 010-1h2a.5.5.0 01.5.5zM3 8a.5.5.0 01-.5.5h-2a.5.5.0 010-1h2A.5.5.0 013 8zm10.657-5.657a.5.5.0 010 .707l-1.414 1.415a.5.5.0 11-.707-.708l1.414-1.414a.5.5.0 01.707.0zm-9.193 9.193a.5.5.0 010 .707L3.05 13.657a.5.5.0 01-.707-.707l1.414-1.414a.5.5.0 01.707.0zm9.193 2.121a.5.5.0 01-.707.0l-1.414-1.414a.5.5.0 01.707-.707l1.414 1.414a.5.5.0 010 .707zM4.464 4.465a.5.5.0 01-.707.0L2.343 3.05a.5.5.0 11.707-.707l1.414 1.414a.5.5.0 010 .708z"/></symbol></svg>
<button class="btn btn-link nav-link dropdown-toggle d-flex align-items-center" id=bd-theme type=button aria-expanded=false data-bs-toggle=dropdown data-bs-display=static aria-label="Toggle theme (auto)"><svg class="bi my-1 theme-icon-active"><use href="#circle-half"/></svg></button><ul class="dropdown-menu dropdown-menu-end" aria-labelledby=bd-theme-text><li><button type=button class="dropdown-item d-flex align-items-center" data-bs-theme-value=light aria-pressed=false>
<svg class="bi me-2 opacity-50"><use href="#sun-fill"/></svg>
Light<svg class="bi ms-auto d-none"><use href="#check2"/></svg></button></li><li><button type=button class="dropdown-item d-flex align-items-center" data-bs-theme-value=dark aria-pressed=false>
<svg class="bi me-2 opacity-50"><use href="#moon-stars-fill"/></svg>
Dark<svg class="bi ms-auto d-none"><use href="#check2"/></svg></button></li><li><button type=button class="dropdown-item d-flex align-items-center active" data-bs-theme-value=auto aria-pressed=true>
<svg class="bi me-2 opacity-50"><use href="#circle-half"/></svg>
Auto<svg class="bi ms-auto d-none"><use href="#check2"/></svg></button></li></ul></li></ul></div><div class="d-none d-lg-block"><div class="td-search td-search--offline"><div class=td-search__icon></div><input type=search class="td-search__input form-control" placeholder="Search this site…" aria-label="Search this site…" autocomplete=off data-offline-search-index-json-src=/offline-search-index.50067a676aae922ae836785e3626a1aa.json data-offline-search-base-href=/ data-offline-search-max-results=10></div></div></div></nav></header><div class="container-fluid td-outer"><div class=td-main><div class="row flex-xl-nowrap"><aside class="col-12 col-md-3 col-xl-2 td-sidebar d-print-none"><div id=td-sidebar-menu class=td-sidebar__inner><form class="td-sidebar__search d-flex align-items-center"><div class="td-search td-search--offline"><div class=td-search__icon></div><input type=search class="td-search__input form-control" placeholder="Search this site…" aria-label="Search this site…" autocomplete=off data-offline-search-index-json-src=/offline-search-index.50067a676aae922ae836785e3626a1aa.json data-offline-search-base-href=/ data-offline-search-max-results=10></div><button class="btn btn-link td-sidebar__toggle d-md-none p-0 ms-3 fas fa-bars" type=button data-bs-toggle=collapse data-bs-target=#td-section-nav aria-controls=td-section-nav aria-expanded=false aria-label="Toggle section navigation"></button></form><nav class="td-sidebar-nav collapse foldable-nav" id=td-section-nav><div class="td-sidebar-nav__section nav-item dropdown d-block d-lg-none"><div class=dropdown><a class="nav-link dropdown-toggle" href=# role=button data-bs-toggle=dropdown aria-haspopup=true aria-expanded=false>English</a><ul class=dropdown-menu><li><a class=dropdown-item href=/cn/docs/user-guide/sql/ddl/create_table/>中文</a></li></ul></div></div><ul class="td-sidebar-nav__section pe-md-3 ul-0"><li class="td-sidebar-nav__section-title td-sidebar-nav__section with-child active-path" id=m-docs-li><a href=/docs/ class="align-left ps-0 td-sidebar-link td-sidebar-link__section tree-root" id=m-docs><span>Docs</span></a><ul class=ul-1><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-docsgetting-started-li><input type=checkbox id=m-docsgetting-started-check>
<label for=m-docsgetting-started-check><a href=/docs/getting-started/ class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id=m-docsgetting-started><span>Getting Started</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section with-child active-path" id=m-docsuser-guide-li><input type=checkbox id=m-docsuser-guide-check checked>
<label for=m-docsuser-guide-check><a href=/docs/user-guide/ class="align-left ps-0 td-sidebar-link td-sidebar-link__section" id=m-docsuser-guide><span>User Guide</span></a></label><ul class="ul-2 foldable"><li class="td-sidebar-nav__section-title td-sidebar-nav__section with-child active-path" id=m-docsuser-guidesql-li><input type=checkbox id=m-docsuser-guidesql-check checked>
<label for=m-docsuser-guidesql-check><a href=/docs/user-guide/sql/ class="align-left ps-0 td-sidebar-link td-sidebar-link__section" id=m-docsuser-guidesql><span>SQL Syntax</span></a></label><ul class="ul-3 foldable"><li class="td-sidebar-nav__section-title td-sidebar-nav__section with-child" id=m-docsuser-guidesqlmodel-li><input type=checkbox id=m-docsuser-guidesqlmodel-check>
<label for=m-docsuser-guidesqlmodel-check><a href=/docs/user-guide/sql/model/ class="align-left ps-0 td-sidebar-link td-sidebar-link__section" id=m-docsuser-guidesqlmodel><span>Data Model</span></a></label><ul class="ul-4 foldable"><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-docsuser-guidesqlmodeldata_types-li><input type=checkbox id=m-docsuser-guidesqlmodeldata_types-check>
<label for=m-docsuser-guidesqlmodeldata_types-check><a href=/docs/user-guide/sql/model/data_types/ class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id=m-docsuser-guidesqlmodeldata_types><span>Data Types</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-docsuser-guidesqlmodelspecial_columns-li><input type=checkbox id=m-docsuser-guidesqlmodelspecial_columns-check>
<label for=m-docsuser-guidesqlmodelspecial_columns-check><a href=/docs/user-guide/sql/model/special_columns/ class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id=m-docsuser-guidesqlmodelspecial_columns><span>Special Columns</span></a></label></li></ul></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-docsuser-guidesqlidentifier-li><input type=checkbox id=m-docsuser-guidesqlidentifier-check>
<label for=m-docsuser-guidesqlidentifier-check><a href=/docs/user-guide/sql/identifier/ class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id=m-docsuser-guidesqlidentifier><span>Identifier</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section with-child active-path" id=m-docsuser-guidesqlddl-li><input type=checkbox id=m-docsuser-guidesqlddl-check checked>
<label for=m-docsuser-guidesqlddl-check><a href=/docs/user-guide/sql/ddl/ class="align-left ps-0 td-sidebar-link td-sidebar-link__section" id=m-docsuser-guidesqlddl><span>Data Definition Statements</span></a></label><ul class="ul-4 foldable"><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-docsuser-guidesqlddlalter_table-li><input type=checkbox id=m-docsuser-guidesqlddlalter_table-check>
<label for=m-docsuser-guidesqlddlalter_table-check><a href=/docs/user-guide/sql/ddl/alter_table/ class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id=m-docsuser-guidesqlddlalter_table><span>ALTER TABLE</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child active-path" id=m-docsuser-guidesqlddlcreate_table-li><input type=checkbox id=m-docsuser-guidesqlddlcreate_table-check checked>
<label for=m-docsuser-guidesqlddlcreate_table-check><a href=/docs/user-guide/sql/ddl/create_table/ class="align-left ps-0 active td-sidebar-link td-sidebar-link__page" id=m-docsuser-guidesqlddlcreate_table><span class=td-sidebar-nav-active-item>CREATE TABLE</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-docsuser-guidesqlddldrop_table-li><input type=checkbox id=m-docsuser-guidesqlddldrop_table-check>
<label for=m-docsuser-guidesqlddldrop_table-check><a href=/docs/user-guide/sql/ddl/drop_table/ class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id=m-docsuser-guidesqlddldrop_table><span>DROP TABLE</span></a></label></li></ul></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section with-child" id=m-docsuser-guidesqldml-li><input type=checkbox id=m-docsuser-guidesqldml-check>
<label for=m-docsuser-guidesqldml-check><a href=/docs/user-guide/sql/dml/ class="align-left ps-0 td-sidebar-link td-sidebar-link__section" id=m-docsuser-guidesqldml><span>Data Manipulation Statements</span></a></label><ul class="ul-4 foldable"><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-docsuser-guidesqldmlinsert-li><input type=checkbox id=m-docsuser-guidesqldmlinsert-check>
<label for=m-docsuser-guidesqldmlinsert-check><a href=/docs/user-guide/sql/dml/insert/ class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id=m-docsuser-guidesqldmlinsert><span>INSERT</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-docsuser-guidesqldmlselect-li><input type=checkbox id=m-docsuser-guidesqldmlselect-check>
<label for=m-docsuser-guidesqldmlselect-check><a href=/docs/user-guide/sql/dml/select/ class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id=m-docsuser-guidesqldmlselect><span>SELECT</span></a></label></li></ul></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-docsuser-guidesqlutility-li><input type=checkbox id=m-docsuser-guidesqlutility-check>
<label for=m-docsuser-guidesqlutility-check><a href=/docs/user-guide/sql/utility/ class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id=m-docsuser-guidesqlutility><span>Utility Statements</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-docsuser-guidesqlengine_options-li><input type=checkbox id=m-docsuser-guidesqlengine_options-check>
<label for=m-docsuser-guidesqlengine_options-check><a href=/docs/user-guide/sql/engine_options/ class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id=m-docsuser-guidesqlengine_options><span>Options</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-docsuser-guidesqlscalar_functions-li><input type=checkbox id=m-docsuser-guidesqlscalar_functions-check>
<label for=m-docsuser-guidesqlscalar_functions-check><a href=/docs/user-guide/sql/scalar_functions/ class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id=m-docsuser-guidesqlscalar_functions><span>Scalar Functions</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-docsuser-guidesqlaggregate_functions-li><input type=checkbox id=m-docsuser-guidesqlaggregate_functions-check>
<label for=m-docsuser-guidesqlaggregate_functions-check><a href=/docs/user-guide/sql/aggregate_functions/ class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id=m-docsuser-guidesqlaggregate_functions><span>Aggregate Functions</span></a></label></li></ul></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section with-child" id=m-docsuser-guidecluster_deployment-li><input type=checkbox id=m-docsuser-guidecluster_deployment-check>
<label for=m-docsuser-guidecluster_deployment-check><a href=/docs/user-guide/cluster_deployment/ class="align-left ps-0 td-sidebar-link td-sidebar-link__section" id=m-docsuser-guidecluster_deployment><span>Cluster Deployment</span></a></label><ul class="ul-3 foldable"><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-docsuser-guidecluster_deploymentno_meta-li><input type=checkbox id=m-docsuser-guidecluster_deploymentno_meta-check>
<label for=m-docsuser-guidecluster_deploymentno_meta-check><a href=/docs/user-guide/cluster_deployment/no_meta/ class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id=m-docsuser-guidecluster_deploymentno_meta><span>NoMeta</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-docsuser-guidecluster_deploymentwith_meta-li><input type=checkbox id=m-docsuser-guidecluster_deploymentwith_meta-check>
<label for=m-docsuser-guidecluster_deploymentwith_meta-check><a href=/docs/user-guide/cluster_deployment/with_meta/ class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id=m-docsuser-guidecluster_deploymentwith_meta><span>WithMeta</span></a></label></li></ul></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section with-child" id=m-docsuser-guidesdk-li><input type=checkbox id=m-docsuser-guidesdk-check>
<label for=m-docsuser-guidesdk-check><a href=/docs/user-guide/sdk/ class="align-left ps-0 td-sidebar-link td-sidebar-link__section" id=m-docsuser-guidesdk><span>SDK</span></a></label><ul class="ul-3 foldable"><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-docsuser-guidesdkgo-li><input type=checkbox id=m-docsuser-guidesdkgo-check>
<label for=m-docsuser-guidesdkgo-check><a href=/docs/user-guide/sdk/go/ class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id=m-docsuser-guidesdkgo><span>Go</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-docsuser-guidesdkjava-li><input type=checkbox id=m-docsuser-guidesdkjava-check>
<label for=m-docsuser-guidesdkjava-check><a href=/docs/user-guide/sdk/java/ class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id=m-docsuser-guidesdkjava><span>Java</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-docsuser-guidesdkpython-li><input type=checkbox id=m-docsuser-guidesdkpython-check>
<label for=m-docsuser-guidesdkpython-check><a href=/docs/user-guide/sdk/python/ class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id=m-docsuser-guidesdkpython><span>Python</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-docsuser-guidesdkrust-li><input type=checkbox id=m-docsuser-guidesdkrust-check>
<label for=m-docsuser-guidesdkrust-check><a href=/docs/user-guide/sdk/rust/ class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id=m-docsuser-guidesdkrust><span>Rust</span></a></label></li></ul></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section with-child" id=m-docsuser-guideoperation-li><input type=checkbox id=m-docsuser-guideoperation-check>
<label for=m-docsuser-guideoperation-check><a href=/docs/user-guide/operation/ class="align-left ps-0 td-sidebar-link td-sidebar-link__section" id=m-docsuser-guideoperation><span>Operation and Maintenance</span></a></label><ul class="ul-3 foldable"><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-docsuser-guideoperationblock_list-li><input type=checkbox id=m-docsuser-guideoperationblock_list-check>
<label for=m-docsuser-guideoperationblock_list-check><a href=/docs/user-guide/operation/block_list/ class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id=m-docsuser-guideoperationblock_list><span>Block List</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-docsuser-guideoperationhoraemeta-li><input type=checkbox id=m-docsuser-guideoperationhoraemeta-check>
<label for=m-docsuser-guideoperationhoraemeta-check><a href=/docs/user-guide/operation/horaemeta/ class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id=m-docsuser-guideoperationhoraemeta><span>Cluster Operation</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-docsuser-guideoperationobservability-li><input type=checkbox id=m-docsuser-guideoperationobservability-check>
<label for=m-docsuser-guideoperationobservability-check><a href=/docs/user-guide/operation/observability/ class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id=m-docsuser-guideoperationobservability><span>Observability</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-docsuser-guideoperationsystem_table-li><input type=checkbox id=m-docsuser-guideoperationsystem_table-check>
<label for=m-docsuser-guideoperationsystem_table-check><a href=/docs/user-guide/operation/system_table/ class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id=m-docsuser-guideoperationsystem_table><span>Table Operation</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-docsuser-guideoperationtable-li><input type=checkbox id=m-docsuser-guideoperationtable-check>
<label for=m-docsuser-guideoperationtable-check><a href=/docs/user-guide/operation/table/ class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id=m-docsuser-guideoperationtable><span>Table Operation</span></a></label></li></ul></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section with-child" id=m-docsuser-guideecosystem-li><input type=checkbox id=m-docsuser-guideecosystem-check>
<label for=m-docsuser-guideecosystem-check><a href=/docs/user-guide/ecosystem/ class="align-left ps-0 td-sidebar-link td-sidebar-link__section" id=m-docsuser-guideecosystem><span>Ecosystem</span></a></label><ul class="ul-3 foldable"><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-docsuser-guideecosysteminfluxdb-li><input type=checkbox id=m-docsuser-guideecosysteminfluxdb-check>
<label for=m-docsuser-guideecosysteminfluxdb-check><a href=/docs/user-guide/ecosystem/influxdb/ class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id=m-docsuser-guideecosysteminfluxdb><span>InfluxDB</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-docsuser-guideecosystemopentsdb-li><input type=checkbox id=m-docsuser-guideecosystemopentsdb-check>
<label for=m-docsuser-guideecosystemopentsdb-check><a href=/docs/user-guide/ecosystem/opentsdb/ class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id=m-docsuser-guideecosystemopentsdb><span>OpenTSDB</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-docsuser-guideecosystemprometheus-li><input type=checkbox id=m-docsuser-guideecosystemprometheus-check>
<label for=m-docsuser-guideecosystemprometheus-check><a href=/docs/user-guide/ecosystem/prometheus/ class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id=m-docsuser-guideecosystemprometheus><span>Prometheus</span></a></label></li></ul></li></ul></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section with-child" id=m-docsdev-li><input type=checkbox id=m-docsdev-check>
<label for=m-docsdev-check><a href=/docs/dev/ class="align-left ps-0 td-sidebar-link td-sidebar-link__section" id=m-docsdev><span>Development</span></a></label><ul class="ul-2 foldable"><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-docsdevplatform-li><input type=checkbox id=m-docsdevplatform-check>
<label for=m-docsdevplatform-check><a href=/docs/dev/platform/ class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id=m-docsdevplatform><span>Supported Platform</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-docsdevconventional_commit-li><input type=checkbox id=m-docsdevconventional_commit-check>
<label for=m-docsdevconventional_commit-check><a href=/docs/dev/conventional_commit/ class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id=m-docsdevconventional_commit><span>Conventional Commit Guide</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-docsdevcompile_run-li><input type=checkbox id=m-docsdevcompile_run-check>
<label for=m-docsdevcompile_run-check><a href=/docs/dev/compile_run/ class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id=m-docsdevcompile_run><span>Compile</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-docsdevprofiling-li><input type=checkbox id=m-docsdevprofiling-check>
<label for=m-docsdevprofiling-check><a href=/docs/dev/profiling/ class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id=m-docsdevprofiling><span>Profiling</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-docsdevstyle_guide-li><input type=checkbox id=m-docsdevstyle_guide-check>
<label for=m-docsdevstyle_guide-check><a href=/docs/dev/style_guide/ class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id=m-docsdevstyle_guide><span>Rationale and Goals</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-docsdevroadmap-li><input type=checkbox id=m-docsdevroadmap-check>
<label for=m-docsdevroadmap-check><a href=/docs/dev/roadmap/ class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id=m-docsdevroadmap><span>RoadMap</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-docsdevsdk_develop-li><input type=checkbox id=m-docsdevsdk_develop-check>
<label for=m-docsdevsdk_develop-check><a href=/docs/dev/sdk_develop/ class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id=m-docsdevsdk_develop><span>SDK Development</span></a></label></li></ul></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section with-child" id=m-docsdesign-li><input type=checkbox id=m-docsdesign-check>
<label for=m-docsdesign-check><a href=/docs/design/ class="align-left ps-0 td-sidebar-link td-sidebar-link__section" id=m-docsdesign><span>Technical and Design</span></a></label><ul class="ul-2 foldable"><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-docsdesigncompaction_offload-li><input type=checkbox id=m-docsdesigncompaction_offload-check>
<label for=m-docsdesigncompaction_offload-check><a href=/docs/design/compaction_offload/ class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id=m-docsdesigncompaction_offload><span>Compaction Offload</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-docsdesignclustering-li><input type=checkbox id=m-docsdesignclustering-check>
<label for=m-docsdesignclustering-check><a href=/docs/design/clustering/ class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id=m-docsdesignclustering><span>Introduction to Architecture of HoraeDB Cluster</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-docsdesignarchitecture-li><input type=checkbox id=m-docsdesignarchitecture-check>
<label for=m-docsdesignarchitecture-check><a href=/docs/design/architecture/ class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id=m-docsdesignarchitecture><span>Introduction to HoraeDB's Architecture</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-docsdesignstorage-li><input type=checkbox id=m-docsdesignstorage-check>
<label for=m-docsdesignstorage-check><a href=/docs/design/storage/ class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id=m-docsdesignstorage><span>Storage</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-docsdesigntable_partitioning-li><input type=checkbox id=m-docsdesigntable_partitioning-check>
<label for=m-docsdesigntable_partitioning-check><a href=/docs/design/table_partitioning/ class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id=m-docsdesigntable_partitioning><span>Table Partitioning</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-docsdesignwal-li><input type=checkbox id=m-docsdesignwal-check>
<label for=m-docsdesignwal-check><a href=/docs/design/wal/ class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id=m-docsdesignwal><span>Wal</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-docsdesignwal_on_disk-li><input type=checkbox id=m-docsdesignwal_on_disk-check>
<label for=m-docsdesignwal_on_disk-check><a href=/docs/design/wal_on_disk/ class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id=m-docsdesignwal_on_disk><span>WAL on Disk</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-docsdesignwal_on_kafka-li><input type=checkbox id=m-docsdesignwal_on_kafka-check>
<label for=m-docsdesignwal_on_kafka-check><a href=/docs/design/wal_on_kafka/ class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id=m-docsdesignwal_on_kafka><span>WAL on Kafka</span></a></label></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-docsdesignwal_on_rocksdb-li><input type=checkbox id=m-docsdesignwal_on_rocksdb-check>
<label for=m-docsdesignwal_on_rocksdb-check><a href=/docs/design/wal_on_rocksdb/ class="align-left ps-0 td-sidebar-link td-sidebar-link__page" id=m-docsdesignwal_on_rocksdb><span>WAL on RocksDB</span></a></label></li></ul></li></ul></li></ul></nav></div></aside><aside class="d-none d-xl-block col-xl-2 td-sidebar-toc d-print-none"><div class="td-page-meta ms-2 pb-1 pt-2 mb-0"><a href=https://github.com/apache/horaedb-docs/tree/main/content/en/docs/user-guide/sql/ddl/create_table.md class="td-page-meta--view td-page-meta__view" target=_blank rel=noopener><i class="fa-solid fa-file-lines fa-fw"></i> View page source</a>
<a href=https://github.com/apache/horaedb-docs/edit/main/content/en/docs/user-guide/sql/ddl/create_table.md class="td-page-meta--edit td-page-meta__edit" target=_blank rel=noopener><i class="fa-solid fa-pen-to-square fa-fw"></i> Edit this page</a>
<a href="https://github.com/apache/horaedb-docs/new/main/content/en/docs/user-guide/sql/ddl?filename=change-me.md&amp;value=---%0Atitle%3A+%22Long+Page+Title%22%0AlinkTitle%3A+%22Short+Nav+Title%22%0Aweight%3A+100%0Adescription%3A+%3E-%0A+++++Page+description+for+heading+and+indexes.%0A---%0A%0A%23%23+Heading%0A%0AEdit+this+template+to+create+your+new+page.%0A%0A%2A+Give+it+a+good+name%2C+ending+in+%60.md%60+-+e.g.+%60getting-started.md%60%0A%2A+Edit+the+%22front+matter%22+section+at+the+top+of+the+page+%28weight+controls+how+its+ordered+amongst+other+pages+in+the+same+directory%3B+lowest+number+first%29.%0A%2A+Add+a+good+commit+message+at+the+bottom+of+the+page+%28%3C80+characters%3B+use+the+extended+description+field+for+more+detail%29.%0A%2A+Create+a+new+branch+so+you+can+preview+your+new+file+and+request+a+review+via+Pull+Request.%0A" class="td-page-meta--child td-page-meta__child" target=_blank rel=noopener><i class="fa-solid fa-pen-to-square fa-fw"></i> Create child page</a>
<a href="https://github.com/apache/horaedb-docs/issues/new?title=CREATE%20TABLE" class="td-page-meta--issue td-page-meta__issue" target=_blank rel=noopener><i class="fa-solid fa-list-check fa-fw"></i> Create documentation issue</a>
<a href=https://github.com/apache/horaedb/issues/new class="td-page-meta--project td-page-meta__project-issue" target=_blank rel=noopener><i class="fa-solid fa-list-check fa-fw"></i> Create project issue</a>
<a id=print href=/docs/user-guide/sql/ddl/_print/><i class="fa-solid fa-print fa-fw"></i> Print entire section</a></div><div class=td-toc><nav id=TableOfContents><ul><li><a href=#basic-syntax>Basic syntax</a></li><li><a href=#if-not-exists>IF NOT EXISTS</a></li><li><a href=#define-column>Define Column</a></li><li><a href=#engine>Engine</a></li><li><a href=#partition-options>Partition Options</a></li></ul></nav></div><div class="taxonomy taxonomy-terms-cloud taxo-tags"><h5 class=taxonomy-title>Tags</h5><ul class=taxonomy-terms><li><a class=taxonomy-term href=https://horaedb.apache.org/tags/release/ data-taxonomy-term=release><span class=taxonomy-label>Release</span><span class=taxonomy-count>1</span></a></li></ul></div></aside><main class="col-12 col-md-9 col-xl-8 ps-md-5" role=main><nav aria-label=breadcrumb class=td-breadcrumbs><ol class=breadcrumb><li class=breadcrumb-item><a href=/docs/>Docs</a></li><li class=breadcrumb-item><a href=/docs/user-guide/>User Guide</a></li><li class=breadcrumb-item><a href=/docs/user-guide/sql/>SQL Syntax</a></li><li class=breadcrumb-item><a href=/docs/user-guide/sql/ddl/>Data Definition Statements</a></li><li class="breadcrumb-item active" aria-current=page>CREATE TABLE</li></ol></nav><div class=td-content><h1>CREATE TABLE</h1><header class=article-meta></header><h2 id=basic-syntax>Basic syntax</h2><p>Basic syntax:</p><div class=highlight><div style=-moz-tab-size:4;-o-tab-size:4;tab-size:4><table style=border-spacing:0;padding:0;margin:0;border:0><tr><td style=vertical-align:top;padding:0;margin:0;border:0><pre tabindex=0 style=-moz-tab-size:4;-o-tab-size:4;tab-size:4><code><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:.4em;padding:0 .4em;color:#7f7f7f">1
</span><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:.4em;padding:0 .4em;color:#7f7f7f">2
</span><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:.4em;padding:0 .4em;color:#7f7f7f">3
</span><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:.4em;padding:0 .4em;color:#7f7f7f">4
</span><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:.4em;padding:0 .4em;color:#7f7f7f">5
</span></code></pre></td><td style=vertical-align:top;padding:0;margin:0;border:0;width:100%><pre tabindex=0 style=-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-sql data-lang=sql><span style=display:flex><span><span style=color:green;font-weight:700>CREATE</span><span style=color:#bbb> </span><span style=color:green;font-weight:700>TABLE</span><span style=color:#bbb> </span>[<span style=color:green;font-weight:700>IF</span><span style=color:#bbb> </span><span style=color:green;font-weight:700>NOT</span><span style=color:#bbb> </span><span style=color:green;font-weight:700>EXISTS</span>]<span style=color:#bbb>
</span></span></span><span style=display:flex><span><span style=color:#bbb> </span><span style=color:green;font-weight:700>table_name</span><span style=color:#bbb> </span>(<span style=color:#bbb> </span>column_definitions<span style=color:#bbb> </span>)<span style=color:#bbb>
</span></span></span><span style=display:flex><span><span style=color:#bbb> </span>[partition_options]<span style=color:#bbb>
</span></span></span><span style=display:flex><span><span style=color:#bbb> </span>ENGINE<span style=color:#bbb> </span><span style=color:#666>=</span><span style=color:#bbb> </span>engine_type<span style=color:#bbb>
</span></span></span><span style=display:flex><span><span style=color:#bbb> </span>[<span style=color:green;font-weight:700>WITH</span><span style=color:#bbb> </span>(<span style=color:#bbb> </span>table_options<span style=color:#bbb> </span>)];<span style=color:#bbb>
</span></span></span></code></pre></td></tr></table></div></div><p>Column definition syntax:</p><div class=highlight><div style=-moz-tab-size:4;-o-tab-size:4;tab-size:4><table style=border-spacing:0;padding:0;margin:0;border:0><tr><td style=vertical-align:top;padding:0;margin:0;border:0><pre tabindex=0 style=-moz-tab-size:4;-o-tab-size:4;tab-size:4><code><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:.4em;padding:0 .4em;color:#7f7f7f">1
</span></code></pre></td><td style=vertical-align:top;padding:0;margin:0;border:0;width:100%><pre tabindex=0 style=-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-sql data-lang=sql><span style=display:flex><span><span style=color:green;font-weight:700>column_name</span><span style=color:#bbb> </span>column_type<span style=color:#bbb> </span>[[<span style=color:green;font-weight:700>NOT</span>]<span style=color:#bbb> </span><span style=color:green;font-weight:700>NULL</span>]<span style=color:#bbb> </span>[TAG<span style=color:#bbb> </span><span style=color:#666>|</span><span style=color:#bbb> </span><span style=color:green;font-weight:700>TIMESTAMP</span><span style=color:#bbb> </span><span style=color:green;font-weight:700>KEY</span><span style=color:#bbb> </span><span style=color:#666>|</span><span style=color:#bbb> </span><span style=color:green;font-weight:700>PRIMARY</span><span style=color:#bbb> </span><span style=color:green;font-weight:700>KEY</span>]<span style=color:#bbb> </span>[<span style=color:green;font-weight:700>DICTIONARY</span>]<span style=color:#bbb> </span>[<span style=color:green;font-weight:700>COMMENT</span><span style=color:#bbb> </span><span style=color:#ba2121>&#39;&#39;</span>]<span style=color:#bbb>
</span></span></span></code></pre></td></tr></table></div></div><p>Partition options syntax:</p><div class=highlight><div style=-moz-tab-size:4;-o-tab-size:4;tab-size:4><table style=border-spacing:0;padding:0;margin:0;border:0><tr><td style=vertical-align:top;padding:0;margin:0;border:0><pre tabindex=0 style=-moz-tab-size:4;-o-tab-size:4;tab-size:4><code><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:.4em;padding:0 .4em;color:#7f7f7f">1
</span></code></pre></td><td style=vertical-align:top;padding:0;margin:0;border:0;width:100%><pre tabindex=0 style=-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-sql data-lang=sql><span style=display:flex><span>PARTITION<span style=color:#bbb> </span><span style=color:green;font-weight:700>BY</span><span style=color:#bbb> </span><span style=color:green;font-weight:700>KEY</span><span style=color:#bbb> </span>(column_list)<span style=color:#bbb> </span>[PARTITIONS<span style=color:#bbb> </span>num]<span style=color:#bbb>
</span></span></span></code></pre></td></tr></table></div></div><p>Table options syntax are key-value pairs. Value should be quoted with quotation marks (<code>'</code>). E.g.:</p><div class=highlight><div style=-moz-tab-size:4;-o-tab-size:4;tab-size:4><table style=border-spacing:0;padding:0;margin:0;border:0><tr><td style=vertical-align:top;padding:0;margin:0;border:0><pre tabindex=0 style=-moz-tab-size:4;-o-tab-size:4;tab-size:4><code><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:.4em;padding:0 .4em;color:#7f7f7f">1
</span></code></pre></td><td style=vertical-align:top;padding:0;margin:0;border:0;width:100%><pre tabindex=0 style=-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-sql data-lang=sql><span style=display:flex><span>...<span style=color:#bbb> </span><span style=color:green;font-weight:700>WITH</span><span style=color:#bbb> </span>(<span style=color:#bbb> </span>enable_ttl<span style=color:#666>=</span><span style=color:#ba2121>&#39;false&#39;</span><span style=color:#bbb> </span>)<span style=color:#bbb>
</span></span></span></code></pre></td></tr></table></div></div><h2 id=if-not-exists>IF NOT EXISTS</h2><p>Add <code>IF NOT EXISTS</code> to tell HoraeDB to ignore errors if the table name already exists.</p><h2 id=define-column>Define Column</h2><p>A column&rsquo;s definition should at least contains the name and type parts. All supported types are listed <a href=/docs/user-guide/sql/model/data_types/>here</a>.</p><p>Column is default be nullable. i.e. <code>NULL</code> keyword is implied. Adding <code>NOT NULL</code> constrains to make it required.</p><div class=highlight><div style=-moz-tab-size:4;-o-tab-size:4;tab-size:4><table style=border-spacing:0;padding:0;margin:0;border:0><tr><td style=vertical-align:top;padding:0;margin:0;border:0><pre tabindex=0 style=-moz-tab-size:4;-o-tab-size:4;tab-size:4><code><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:.4em;padding:0 .4em;color:#7f7f7f">1
</span><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:.4em;padding:0 .4em;color:#7f7f7f">2
</span><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:.4em;padding:0 .4em;color:#7f7f7f">3
</span><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:.4em;padding:0 .4em;color:#7f7f7f">4
</span><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:.4em;padding:0 .4em;color:#7f7f7f">5
</span><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:.4em;padding:0 .4em;color:#7f7f7f">6
</span><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:.4em;padding:0 .4em;color:#7f7f7f">7
</span></code></pre></td><td style=vertical-align:top;padding:0;margin:0;border:0;width:100%><pre tabindex=0 style=-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-sql data-lang=sql><span style=display:flex><span><span style=color:#408080;font-style:italic>-- this definition
</span></span></span><span style=display:flex><span><span style=color:#408080;font-style:italic></span>a_nullable<span style=color:#bbb> </span><span style=color:green>int</span><span style=color:#bbb>
</span></span></span><span style=display:flex><span><span style=color:#bbb></span><span style=color:#408080;font-style:italic>-- equals to
</span></span></span><span style=display:flex><span><span style=color:#408080;font-style:italic></span>a_nullable<span style=color:#bbb> </span><span style=color:green>int</span><span style=color:#bbb> </span><span style=color:green;font-weight:700>NULL</span><span style=color:#bbb>
</span></span></span><span style=display:flex><span><span style=color:#bbb>
</span></span></span><span style=display:flex><span><span style=color:#bbb></span><span style=color:#408080;font-style:italic>-- add NOT NULL to make it required
</span></span></span><span style=display:flex><span><span style=color:#408080;font-style:italic></span>b_not_null<span style=color:#bbb> </span><span style=color:green;font-weight:700>NOT</span><span style=color:#bbb> </span><span style=color:green;font-weight:700>NULL</span><span style=color:#bbb>
</span></span></span></code></pre></td></tr></table></div></div><p>A column can be marked as <a href=/docs/user-guide/sql/model/special_columns/>special column</a> with related keyword.</p><p>For string tag column, we recommend to define it as dictionary to reduce memory consumption:</p><div class=highlight><div style=-moz-tab-size:4;-o-tab-size:4;tab-size:4><table style=border-spacing:0;padding:0;margin:0;border:0><tr><td style=vertical-align:top;padding:0;margin:0;border:0><pre tabindex=0 style=-moz-tab-size:4;-o-tab-size:4;tab-size:4><code><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:.4em;padding:0 .4em;color:#7f7f7f">1
</span></code></pre></td><td style=vertical-align:top;padding:0;margin:0;border:0;width:100%><pre tabindex=0 style=-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-sql data-lang=sql><span style=display:flex><span><span style=color:#666>`</span>tag1<span style=color:#666>`</span><span style=color:#bbb> </span>string<span style=color:#bbb> </span>TAG<span style=color:#bbb> </span><span style=color:green;font-weight:700>DICTIONARY</span><span style=color:#bbb>
</span></span></span></code></pre></td></tr></table></div></div><h2 id=engine>Engine</h2><p>Specifies which engine this table belongs to. HoraeDB current support <code>Analytic</code> engine type. This attribute is immutable.</p><h2 id=partition-options>Partition Options</h2><blockquote><p>Note: This feature is only supported in distributed version.</p></blockquote><div class=highlight><div style=-moz-tab-size:4;-o-tab-size:4;tab-size:4><table style=border-spacing:0;padding:0;margin:0;border:0><tr><td style=vertical-align:top;padding:0;margin:0;border:0><pre tabindex=0 style=-moz-tab-size:4;-o-tab-size:4;tab-size:4><code><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:.4em;padding:0 .4em;color:#7f7f7f">1
</span></code></pre></td><td style=vertical-align:top;padding:0;margin:0;border:0;width:100%><pre tabindex=0 style=-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-sql data-lang=sql><span style=display:flex><span><span style=color:green;font-weight:700>CREATE</span><span style=color:#bbb> </span><span style=color:green;font-weight:700>TABLE</span><span style=color:#bbb> </span>...<span style=color:#bbb> </span>PARTITION<span style=color:#bbb> </span><span style=color:green;font-weight:700>BY</span><span style=color:#bbb> </span><span style=color:green;font-weight:700>KEY</span><span style=color:#bbb>
</span></span></span></code></pre></td></tr></table></div></div><p>Example below creates a table with 8 partitions, and partitioned by <code>name</code>:</p><div class=highlight><div style=-moz-tab-size:4;-o-tab-size:4;tab-size:4><table style=border-spacing:0;padding:0;margin:0;border:0><tr><td style=vertical-align:top;padding:0;margin:0;border:0><pre tabindex=0 style=-moz-tab-size:4;-o-tab-size:4;tab-size:4><code><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:.4em;padding:0 .4em;color:#7f7f7f"> 1
</span><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:.4em;padding:0 .4em;color:#7f7f7f"> 2
</span><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:.4em;padding:0 .4em;color:#7f7f7f"> 3
</span><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:.4em;padding:0 .4em;color:#7f7f7f"> 4
</span><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:.4em;padding:0 .4em;color:#7f7f7f"> 5
</span><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:.4em;padding:0 .4em;color:#7f7f7f"> 6
</span><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:.4em;padding:0 .4em;color:#7f7f7f"> 7
</span><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:.4em;padding:0 .4em;color:#7f7f7f"> 8
</span><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:.4em;padding:0 .4em;color:#7f7f7f"> 9
</span><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:.4em;padding:0 .4em;color:#7f7f7f">10
</span><span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:.4em;padding:0 .4em;color:#7f7f7f">11
</span></code></pre></td><td style=vertical-align:top;padding:0;margin:0;border:0;width:100%><pre tabindex=0 style=-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-sql data-lang=sql><span style=display:flex><span><span style=color:green;font-weight:700>CREATE</span><span style=color:#bbb> </span><span style=color:green;font-weight:700>TABLE</span><span style=color:#bbb> </span><span style=color:#666>`</span>demo<span style=color:#666>`</span><span style=color:#bbb> </span>(<span style=color:#bbb>
</span></span></span><span style=display:flex><span><span style=color:#bbb> </span><span style=color:#666>`</span>name<span style=color:#666>`</span><span style=color:#bbb> </span>string<span style=color:#bbb> </span>TAG<span style=color:#bbb> </span><span style=color:green;font-weight:700>COMMENT</span><span style=color:#bbb> </span><span style=color:#ba2121>&#39;client username&#39;</span>,<span style=color:#bbb>
</span></span></span><span style=display:flex><span><span style=color:#bbb> </span><span style=color:#666>`</span>value<span style=color:#666>`</span><span style=color:#bbb> </span>double<span style=color:#bbb> </span><span style=color:green;font-weight:700>NOT</span><span style=color:#bbb> </span><span style=color:green;font-weight:700>NULL</span>,<span style=color:#bbb>
</span></span></span><span style=display:flex><span><span style=color:#bbb> </span><span style=color:#666>`</span>t<span style=color:#666>`</span><span style=color:#bbb> </span><span style=color:green;font-weight:700>timestamp</span><span style=color:#bbb> </span><span style=color:green;font-weight:700>NOT</span><span style=color:#bbb> </span><span style=color:green;font-weight:700>NULL</span>,<span style=color:#bbb>
</span></span></span><span style=display:flex><span><span style=color:#bbb> </span><span style=color:green;font-weight:700>timestamp</span><span style=color:#bbb> </span><span style=color:green;font-weight:700>KEY</span><span style=color:#bbb> </span>(t)<span style=color:#bbb>
</span></span></span><span style=display:flex><span><span style=color:#bbb></span>)<span style=color:#bbb>
</span></span></span><span style=display:flex><span><span style=color:#bbb> </span>PARTITION<span style=color:#bbb> </span><span style=color:green;font-weight:700>BY</span><span style=color:#bbb> </span><span style=color:green;font-weight:700>KEY</span>(name)<span style=color:#bbb> </span>PARTITIONS<span style=color:#bbb> </span><span style=color:#666>8</span><span style=color:#bbb>
</span></span></span><span style=display:flex><span><span style=color:#bbb> </span>ENGINE<span style=color:#666>=</span>Analytic<span style=color:#bbb>
</span></span></span><span style=display:flex><span><span style=color:#bbb> </span><span style=color:green;font-weight:700>with</span><span style=color:#bbb> </span>(<span style=color:#bbb>
</span></span></span><span style=display:flex><span><span style=color:#bbb> </span>enable_ttl<span style=color:#666>=</span><span style=color:#ba2121>&#39;false&#39;</span><span style=color:#bbb>
</span></span></span><span style=display:flex><span><span style=color:#bbb></span>)<span style=color:#bbb>
</span></span></span></code></pre></td></tr></table></div></div><div class=td-page-meta__lastmod>Last modified August 21, 2024: <a href=https://github.com/apache/horaedb-docs/commit/36785ca3da45c2b6ac45fbd16916ead7ef98b2cf>refactor: use hugo to build website (#132) (36785ca)</a></div></div></main></div></div><footer class="td-footer row d-print-none"><div class=container-fluid><div class="row mx-md-2"><div class=td-footer__center>Apache HoraeDB is an effort undergoing incubation at The Apache Software Foundation (ASF), sponsored by the Apache Incubator. Incubation is required of all newly accepted projects until a further review indicates that the infrastructure, communications, and decision making process have stabilized in a manner consistent with other successful ASF projects. While incubation status is not necessarily a reflection of the completeness or stability of the code, it does indicate that the project has yet to be fully endorsed by the ASF.<hr><span class=td-footer__copyright>&copy;
2023&ndash;2024
<span class=td-footer__authors><p>The Apache Software Foundation, Licensed under the Apache License, Version 2.0.</p><p>Apache, the names of Apache projects, and the feather logo are either registered trademarks or trademarks of the Apache Software Foundation in the United States and/or other countries.</p></span></span><span class=td-footer__all_rights_reserved>All Rights Reserved</span></div></div><hr><div class="row mx-md-2"><div class=td-footer__center><span class=td-footer__copyright>Found a bug in website? <a href=https://github.com/apache/horaedb-docs/issues/new>Open an issue</a> or <a href=https://github.com/apache/horaedb-docs/pulls>submit a pull request</a> on GitHub.</span></div></div><hr></div></footer></div><script src=/js/main.min.f72d00502781aaf278a14088eb2356b1ba2a05ad698a0c43fe86314d74ceab56.js integrity="sha256-9y0AUCeBqvJ4oUCI6yNWsboqBa1pigxD/oYxTXTOq1Y=" crossorigin=anonymous></script><script defer src=/js/click-to-copy.min.73478a7d4807698aed7e355eb23f9890ca18fea3158604c8471746d046702bad.js integrity="sha256-c0eKfUgHaYrtfjVesj+YkMoY/qMVhgTIRxdG0EZwK60=" crossorigin=anonymous></script><script src=/js/tabpane-persist.js></script></body></html>