blob: b22cf9dd7f18ca372b98dc1efa87ab818c5b5ee2 [file] [log] [blame]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>Data Definition | Apache Cassandra Documentation</title>
<link rel="stylesheet" href="../../../../../assets/css/site.css">
<link rel="schema.dcterms" href="https://purl.org/dc/terms/">
<meta name="dcterms.subject" content="Cassandra">
<meta name="dcterms.identifier" content="5.0">
<meta name="generator" content="Antora 2.3.4">
<link rel="icon" href="../../../../../assets/img/favicon.ico" type="image/x-icon">
<script>
const script = document.createElement("script");
const domain = window.location.hostname;
script.type = "text/javascript";
script.src = "https://plausible.cassandra.apache.org/js/plausible.js";
script.setAttribute("data-domain",domain);
script.setAttribute("defer",'true');
script.setAttribute("async",'true');
document.getElementsByTagName("head")[0].appendChild(script);
</script> </head>
<body class="docs-wrapper article">
<div class="container mx-auto relative">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<meta property="og:type" content="website" />
<meta property="og:url" content="/" />
<meta property="og:site_name" content="Apache Cassandra" />
<header id="top-nav">
<div class="inner relative">
<div class="header-social-icons text-right">
<a href="https://twitter.com/cassandra?lang=en" target="_blank" styles="margin-left: 20px;"><img src="../../../../../assets/img/twitter-icon-circle-white.svg" alt="twitter icon" width="24"></a>
<a href="https://www.linkedin.com/company/apache-cassandra/" target="_blank" styles="margin-left: 20px;"><img src="../../../../../assets/img/LI-In-Bug.png" alt="linked-in icon" width="24"></a>
<a href="https://www.youtube.com/c/PlanetCassandra" target="_blank" styles="margin-left: 20px;"><img src="../../../../../assets/img/youtube-icon.png" alt="youtube icon" width="24"></a>
</div>
<div class="cf">
<div class="logo left"><a href="/"><img src="../../../../../assets/img/logo-white-r.png" alt="Cassandra Logo"></a></div>
<div class="mobile-nav-icon right">
<img class="toggle-icon" src="../../../../../assets/img/hamburger-nav.svg">
</div>
<ul class="main-nav nav-links right flex flex-vert-center flex-space-between">
<li>
<a class="nav-link hide-mobile">Get Started</a>
<ul class="sub-menu bg-white">
<li class="pa-micro">
<a href="/_/cassandra-basics.html">
<div class="sub-nav-icon">
<img src="../../../../../assets/img/sub-menu-basics.png" alt="cassandra basics icon">
</div>
<div class="sub-nav-text teal py-small">
Cassandra Basics
</div>
</a>
</li>
<li class="pa-micro">
<a href="/_/quickstart.html">
<div class="sub-nav-icon">
<img src="../../../../../assets/img/sub-menu-rocket.png" alt="cassandra basics icon">
</div>
<div class="sub-nav-text teal py-small">
Quickstart
</div>
</a>
</li>
<li class="pa-micro">
<a href="/_/ecosystem.html">
<div class="sub-nav-icon">
<img src="../../../../../assets/img/sub-menu-ecosystem.png" alt="cassandra basics icon">
</div>
<div class="sub-nav-text teal py-small">
Ecosystem
</div>
</a>
</li>
</ul>
</li>
<li><a class="nav-link" href="/doc/latest/">Documentation</a></li>
<li>
<a class="nav-link" href="/_/community.html">Community</a>
<ul class="sub-menu bg-white">
<li class="pa-micro">
<a href="/_/community.html#code-of-conduct">
<div class="sub-nav-icon">
<img src="../../../../../assets/img/sub-menu-welcome.png" alt="welcome icon">
</div>
<div class="sub-nav-text teal py-small">
Welcome
</div>
</a>
</li>
<li class="pa-micro hide-mobile">
<a href="/_/community.html#discussions">
<div class="sub-nav-icon">
<img src="../../../../../assets/img/sub-menu-discussions.png" alt="discussions icon">
</div>
<div class="sub-nav-text teal py-small">
Discussions
</div>
</a>
</li>
<li class="pa-micro hide-mobile">
<a href="/_/community.html#project-governance">
<div class="sub-nav-icon">
<img src="../../../../../assets/img/sub-menu-governance.png" alt="Governance icon">
</div>
<div class="sub-nav-text teal py-small">
Governance
</div>
</a>
</li>
<li class="pa-micro hide-mobile">
<a href="/_/community.html#how-to-contribute">
<div class="sub-nav-icon">
<img src="../../../../../assets/img/sub-menu-contribute.png" alt="Contribute icon">
</div>
<div class="sub-nav-text teal py-small">
Contribute
</div>
</a>
</li>
<li class="pa-micro hide-mobile">
<a href="/_/community.html#meet-the-community">
<div class="sub-nav-icon">
<img src="../../../../../assets/img/sub-menu-community.png" alt="Meet the Community icon">
</div>
<div class="sub-nav-text teal py-small">
Meet the Community
</div>
</a>
</li>
<li class="pa-micro hide-mobile">
<a href="/_/cassandra-catalyst-program.html">
<div class="sub-nav-icon">
<img src="../../../../../assets/img/sub-menu-catalyst.png" alt="Catalyst icon">
</div>
<div class="sub-nav-text teal py-small">
Catalyst Program
</div>
</a>
</li>
<li class="pa-micro hide-mobile">
<a href="/_/events.html">
<div class="sub-nav-icon">
<img src="../../../../../assets/img/sub-menu-events.png" alt="Events icon">
</div>
<div class="sub-nav-text teal py-small">
Events
</div>
</a>
</li>
</ul>
</li>
<li>
<a class="nav-link hide-mobile">Learn</a>
<ul class="sub-menu bg-white">
<li class="pa-micro">
<a href="/_/Apache-Cassandra-5.0-Moving-Toward-an-AI-Driven-Future.html">
<div class="sub-nav-icon">
<img src="../../../../../assets/img/sub-menu-basics.png" alt="Basics icon">
</div>
<div class="sub-nav-text teal py-small">
Cassandra 5.0
</div>
</a>
</li>
<li class="pa-micro">
<a href="/_/case-studies.html">
<div class="sub-nav-icon">
<img src="../../../../../assets/img/sub-menu-case-study.png" alt="Case Studies icon">
</div>
<div class="sub-nav-text teal py-small">
Case Studies
</div>
</a>
</li>
<li class="pa-micro">
<a href="/_/resources.html">
<div class="sub-nav-icon">
<img src="../../../../../assets/img/sub-menu-resources.png" alt="Resources icon">
</div>
<div class="sub-nav-text teal py-small">
Resources
</div>
</a>
</li>
<li class="pa-micro">
<a href="/_/blog.html">
<div class="sub-nav-icon">
<img src="../../../../../assets/img/sub-menu-blog.png" alt="Blog icon">
</div>
<div class="sub-nav-text teal py-small">
Blog
</div>
</a>
</li>
</ul>
</li>
<li><a class="nav-link btn btn--filled" href="/_/download.html">Download Now</a></li>
</ul>
</div>
</div>
</header>
<div class="hero hero--home grad">
<div class="eye"></div>
<div id="docs-content" class="text-center flex flex-center flex-column relative z2 ma-xlarge">
<h2>Cassandra Documentation</h2>
</div>
</div>
<div class="body px-medium py-medium container">
<div class="docs-nav-bar flex flex-space-between mb-medium">
<div id="mobile-docs-nav-burger" class="hidden">
<svg viewBox="0 0 24 24" width="36" height="36" stroke="#1c81a0" stroke-width="2.5" fill="none" stroke-linecap="round" stroke-linejoin="round" class="css-i6dzq1"><line x1="3" y1="12" x2="21" y2="12"></line><line x1="3" y1="6" x2="21" y2="6"></line><line x1="3" y1="18" x2="21" y2="18"></line></svg>
</div>
<div class="docs-nav-item relative">
<input id="search-input" type="text" placeholder="Search docs">
</div>
<div class="versions-wrapper">
<h4>Version:</h4>
<div class="nav-panel-explore" data-panel="explore">
<div id="version-toggle" class="context">
<span class="version">5.0</span>
</div>
<ul id="versions-list" class="components">
<li class="component">
<ul class="versions">
<li class="version is-latest">
<a href="../../../../../_/index.html">master</a>
</li>
</ul>
</li>
<li class="component is-current">
<ul class="versions">
<li class="version">
<a href="../../../../trunk/index.html">trunk</a>
</li>
<li class="version is-current">
<a href="../../../index.html">5.0</a>
</li>
<li class="version is-latest">
<a href="../../../../4.1/index.html">4.1</a>
</li>
<li class="version">
<a href="../../../../4.0/index.html">4.0</a>
</li>
<li class="version">
<a href="../../../../3.11/index.html">3.11</a>
</li>
</ul>
</li>
</ul>
</div>
</div> </div>
<div class="cf relative">
<nav class="nav docs-nav full-800">
<div class="nav-menu">
<ul class="nav-list">
<li class="nav-item is-active" data-depth="0">
<ul class="nav-list">
<li class="nav-item" data-depth="1">
<span class="nav-line">
<button class="nav-toggle"></button>
<a class="nav-link" href="../../../index.html">Main</a>
</span>
<ul class="nav-list">
<li class="nav-item" data-depth="2">
<span class="nav-line">
<a class="nav-link" href="../../../../../_/glossary.html">Glossary</a>
</span>
</li>
<li class="nav-item" data-depth="2">
<span class="nav-line">
<a class="nav-link" href="../../../../../_/bugs.html">How to report bugs</a>
</span>
</li>
<li class="nav-item" data-depth="2">
<span class="nav-line">
<a class="nav-link" href="../../../../../_/contactus.html">Contact us</a>
</span>
</li>
<li class="nav-item" data-depth="2">
<span class="nav-line">
<button class="nav-toggle"></button>
<a class="nav-link" href="../../../../../_/development/index.html">Development</a>
</span>
<ul class="nav-list">
<li class="nav-item" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="../../../../../_/development/gettingstarted.html">Getting started</a>
</span>
</li>
<li class="nav-item" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="../../../../../_/development/ide.html">Building and IDE integration</a>
</span>
</li>
<li class="nav-item" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="../../../../../_/development/testing.html">Testing</a>
</span>
</li>
<li class="nav-item" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="../../../../../_/development/patches.html">Contributing code changes</a>
</span>
</li>
<li class="nav-item" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="../../../../../_/development/code_style.html">Code style</a>
</span>
</li>
<li class="nav-item" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="../../../../../_/development/how_to_review.html">Review checklist</a>
</span>
</li>
<li class="nav-item" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="../../../../../_/development/how_to_commit.html">How to commit</a>
</span>
</li>
<li class="nav-item" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="../../../../../_/development/documentation.html">Working on documentation</a>
</span>
</li>
<li class="nav-item" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="../../../../../_/development/ci.html">Jenkins CI environment</a>
</span>
</li>
<li class="nav-item" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="../../../../../_/development/dependencies.html">Dependency management</a>
</span>
</li>
<li class="nav-item" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="../../../../../_/development/release_process.html">Release process</a>
</span>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li class="nav-item is-active" data-depth="0">
<ul class="nav-list">
<li class="nav-item is-current-path is-active" data-depth="1">
<span class="nav-line">
<button class="nav-toggle"></button>
<span class="nav-text">Cassandra</span>
</span>
<ul class="nav-list">
<li class="nav-item" data-depth="2">
<span class="nav-line">
<a class="nav-link" href="../../overview/faq/index.html">FAQ</a>
</span>
</li>
<li class="nav-item" data-depth="2">
<span class="nav-line">
<button class="nav-toggle"></button>
<a class="nav-link" href="../../getting-started/index.html">Getting Started</a>
</span>
<ul class="nav-list">
<li class="nav-item" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="../../getting-started/cassandra-quickstart.html">Cassandra Quickstart</a>
</span>
</li>
<li class="nav-item" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="../../getting-started/sai-quickstart.html">SAI Quickstart</a>
</span>
</li>
<li class="nav-item" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="../../getting-started/vector-search-quickstart.html">Vector Search Quickstart</a>
</span>
</li>
<li class="nav-item" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="../../installing/installing.html">Installing Cassandra</a>
</span>
</li>
<li class="nav-item" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="../../getting-started/configuring.html">Configuring Cassandra</a>
</span>
</li>
<li class="nav-item" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="../../getting-started/querying.html">Inserting and querying</a>
</span>
</li>
<li class="nav-item" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="../../getting-started/drivers.html">Client drivers</a>
</span>
</li>
<li class="nav-item" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="../../getting-started/production.html">Production recommendations</a>
</span>
</li>
</ul>
</li>
<li class="nav-item" data-depth="2">
<span class="nav-line">
<button class="nav-toggle"></button>
<a class="nav-link" href="../../new/index.html">What&#8217;s new</a>
</span>
<ul class="nav-list">
<li class="nav-item" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="../../reference/java17.html">Support for Java</a>
</span>
</li>
</ul>
</li>
<li class="nav-item" data-depth="2">
<span class="nav-line">
<button class="nav-toggle"></button>
<a class="nav-link" href="../../architecture/index.html">Architecture</a>
</span>
<ul class="nav-list">
<li class="nav-item" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="../../architecture/overview.html">Overview</a>
</span>
</li>
<li class="nav-item" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="../../architecture/dynamo.html">Dynamo</a>
</span>
</li>
<li class="nav-item" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="../../architecture/storage-engine.html">Storage Engine</a>
</span>
</li>
<li class="nav-item" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="../../architecture/guarantees.html">Guarantees</a>
</span>
</li>
<li class="nav-item" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="../../architecture/messaging.html">Improved Internode Messaging</a>
</span>
</li>
<li class="nav-item" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="../../architecture/streaming.html">Improved Streaming</a>
</span>
</li>
</ul>
</li>
<li class="nav-item" data-depth="2">
<span class="nav-line">
<button class="nav-toggle"></button>
<a class="nav-link" href="../data-modeling/index.html">Data Modeling</a>
</span>
<ul class="nav-list">
<li class="nav-item" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="../data-modeling/intro.html">Introduction</a>
</span>
</li>
<li class="nav-item" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="../data-modeling/data-modeling_conceptual.html">Conceptual data modeling</a>
</span>
</li>
<li class="nav-item" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="../data-modeling/data-modeling_rdbms.html">RDBMS design</a>
</span>
</li>
<li class="nav-item" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="../data-modeling/data-modeling_queries.html">Defining application queries</a>
</span>
</li>
<li class="nav-item" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="../data-modeling/data-modeling_logical.html">Logical data modeling</a>
</span>
</li>
<li class="nav-item" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="../data-modeling/data-modeling_physical.html">Physical data modeling</a>
</span>
</li>
<li class="nav-item" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="../data-modeling/data-modeling_refining.html">Evaluating and refining data models</a>
</span>
</li>
<li class="nav-item" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="../data-modeling/data-modeling_schema.html">Defining database schema</a>
</span>
</li>
<li class="nav-item" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="../data-modeling/data-modeling_tools.html">Cassandra data modeling tools</a>
</span>
</li>
</ul>
</li>
<li class="nav-item is-current-path is-active" data-depth="2">
<span class="nav-line">
<button class="nav-toggle"></button>
<a class="nav-link" href="index.html">Cassandra Query Language (CQL)</a>
</span>
<ul class="nav-list">
<li class="nav-item" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="definitions.html">Definitions</a>
</span>
</li>
<li class="nav-item" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="types.html">Data types</a>
</span>
</li>
<li class="nav-item is-current-page is-active" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="ddl.html">Data definition (DDL)</a>
</span>
</li>
<li class="nav-item" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="dml.html">Data manipulation (DML)</a>
</span>
</li>
<li class="nav-item" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="dynamic-data-masking.html">Dynamic Data Masking (DDM)</a>
</span>
</li>
<li class="nav-item" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="operators.html">Operators</a>
</span>
</li>
<li class="nav-item" data-depth="3">
<span class="nav-line">
<button class="nav-toggle"></button>
<a class="nav-link" href="indexing/indexing-concepts.html">Indexing concepts</a>
</span>
<ul class="nav-list">
<li class="nav-item" data-depth="4">
<span class="nav-line">
<button class="nav-toggle"></button>
<a class="nav-link" href="indexing/sai/sai-overview.html">SAI Overview</a>
</span>
<ul class="nav-list">
<li class="nav-item" data-depth="5">
<span class="nav-line">
<a class="nav-link" href="indexing/sai/sai-concepts.html">Concepts</a>
</span>
</li>
<li class="nav-item" data-depth="5">
<span class="nav-line">
<a class="nav-link" href="../../getting-started/sai-quickstart.html">SAI Quickstart</a>
</span>
</li>
<li class="nav-item" data-depth="5">
<span class="nav-line">
<a class="nav-link" href="indexing/sai/sai-faq.html">SAI FAQ</a>
</span>
</li>
<li class="nav-item" data-depth="5">
<span class="nav-line">
<a class="nav-link" href="indexing/sai/sai-working-with.html">Working with SAI</a>
</span>
</li>
<li class="nav-item" data-depth="5">
<span class="nav-line">
<a class="nav-link" href="indexing/sai/operations/sai-operations.html">SAI operations</a>
</span>
</li>
</ul>
</li>
<li class="nav-item" data-depth="4">
<span class="nav-line">
<button class="nav-toggle"></button>
<a class="nav-link" href="indexing/2i/2i-overview.html">Secondary indexes (2i) overview</a>
</span>
<ul class="nav-list">
<li class="nav-item" data-depth="5">
<span class="nav-line">
<a class="nav-link" href="indexing/2i/2i-concepts.html">Concepts</a>
</span>
</li>
<li class="nav-item" data-depth="5">
<span class="nav-line">
<a class="nav-link" href="indexing/2i/2i-working-with.html">Working with 2i</a>
</span>
</li>
<li class="nav-item" data-depth="5">
<span class="nav-line">
<a class="nav-link" href="indexing/2i/operations/2i-build.html">Rebuild 2i</a>
</span>
</li>
</ul>
</li>
</ul>
</li>
<li class="nav-item" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="mvs.html">Materialized views</a>
</span>
</li>
<li class="nav-item" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="functions.html">Functions</a>
</span>
</li>
<li class="nav-item" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="json.html">JSON</a>
</span>
</li>
<li class="nav-item" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="security.html">Security</a>
</span>
</li>
<li class="nav-item" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="triggers.html">Triggers</a>
</span>
</li>
<li class="nav-item" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="appendices.html">Appendices</a>
</span>
</li>
<li class="nav-item" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="changes.html">Changes</a>
</span>
</li>
<li class="nav-item" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="SASI.html">SASI</a>
</span>
</li>
<li class="nav-item" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="cql_singlefile.html">Single file of CQL information</a>
</span>
</li>
</ul>
</li>
<li class="nav-item" data-depth="2">
<span class="nav-line">
<button class="nav-toggle"></button>
<a class="nav-link" href="../../vector-search/overview.html">Vector Search overview</a>
</span>
<ul class="nav-list">
<li class="nav-item" data-depth="3">
<span class="nav-line">
<button class="nav-toggle"></button>
<a class="nav-link" href="../../vector-search/concepts.html">Concepts</a>
</span>
<ul class="nav-list">
<li class="nav-item" data-depth="4">
<span class="nav-line">
<a class="nav-link" href="../../vector-search/data-modeling.html">Data Modeling</a>
</span>
</li>
</ul>
</li>
<li class="nav-item" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="../../getting-started/vector-search-quickstart.html">Vector Search Quickstart</a>
</span>
</li>
<li class="nav-item" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="../../vector-search/vector-search-working-with.html">Working with Vector Search</a>
</span>
</li>
</ul>
</li>
<li class="nav-item" data-depth="2">
<span class="nav-line">
<button class="nav-toggle"></button>
<a class="nav-link" href="../../managing/index.html">Managing</a>
</span>
<ul class="nav-list">
<li class="nav-item" data-depth="3">
<span class="nav-line">
<button class="nav-toggle"></button>
<a class="nav-link" href="../../managing/configuration/index.html">Configuring</a>
</span>
<ul class="nav-list">
<li class="nav-item" data-depth="4">
<span class="nav-line">
<a class="nav-link" href="../../managing/configuration/cass_yaml_file.html">cassandra.yaml</a>
</span>
</li>
<li class="nav-item" data-depth="4">
<span class="nav-line">
<a class="nav-link" href="../../managing/configuration/cass_rackdc_file.html">cassandra-rackdc.properties</a>
</span>
</li>
<li class="nav-item" data-depth="4">
<span class="nav-line">
<a class="nav-link" href="../../managing/configuration/cass_env_sh_file.html">cassandra-env.sh</a>
</span>
</li>
<li class="nav-item" data-depth="4">
<span class="nav-line">
<a class="nav-link" href="../../managing/configuration/cass_topo_file.html">cassandra-topologies.properties</a>
</span>
</li>
<li class="nav-item" data-depth="4">
<span class="nav-line">
<a class="nav-link" href="../../managing/configuration/cass_cl_archive_file.html">commitlog-archiving.properties</a>
</span>
</li>
<li class="nav-item" data-depth="4">
<span class="nav-line">
<a class="nav-link" href="../../managing/configuration/cass_logback_xml_file.html">logback.xml</a>
</span>
</li>
<li class="nav-item" data-depth="4">
<span class="nav-line">
<a class="nav-link" href="../../managing/configuration/cass_jvm_options_file.html">jvm-* files</a>
</span>
</li>
<li class="nav-item" data-depth="4">
<span class="nav-line">
<a class="nav-link" href="../../managing/configuration/configuration.html">Liberating cassandra.yaml Parameters' Names from Their Units</a>
</span>
</li>
</ul>
</li>
<li class="nav-item" data-depth="3">
<span class="nav-line">
<button class="nav-toggle"></button>
<a class="nav-link" href="../../managing/operating/index.html">Operating</a>
</span>
<ul class="nav-list">
<li class="nav-item" data-depth="4">
<span class="nav-line">
<a class="nav-link" href="../../managing/operating/backups.html">Backups</a>
</span>
</li>
<li class="nav-item" data-depth="4">
<span class="nav-line">
<a class="nav-link" href="../../managing/operating/bloom_filters.html">Bloom filters</a>
</span>
</li>
<li class="nav-item" data-depth="4">
<span class="nav-line">
<a class="nav-link" href="../../managing/operating/bulk_loading.html">Bulk loading</a>
</span>
</li>
<li class="nav-item" data-depth="4">
<span class="nav-line">
<a class="nav-link" href="../../managing/operating/cdc.html">Change Data Capture (CDC)</a>
</span>
</li>
<li class="nav-item" data-depth="4">
<span class="nav-line">
<a class="nav-link" href="../../managing/operating/compaction/index.html">Compaction</a>
</span>
</li>
<li class="nav-item" data-depth="4">
<span class="nav-line">
<a class="nav-link" href="../../managing/operating/compression.html">Compression</a>
</span>
</li>
<li class="nav-item" data-depth="4">
<span class="nav-line">
<a class="nav-link" href="../../managing/operating/hardware.html">Hardware</a>
</span>
</li>
<li class="nav-item" data-depth="4">
<span class="nav-line">
<a class="nav-link" href="../../managing/operating/hints.html">Hints</a>
</span>
</li>
<li class="nav-item" data-depth="4">
<span class="nav-line">
<button class="nav-toggle"></button>
<a class="nav-link" href="../../managing/operating/logging.html">Logging</a>
</span>
<ul class="nav-list">
<li class="nav-item" data-depth="5">
<span class="nav-line">
<a class="nav-link" href="../../managing/operating/auditlogging.html">Audit logging</a>
</span>
</li>
<li class="nav-item" data-depth="5">
<span class="nav-line">
<a class="nav-link" href="../../managing/operating/audit_logging.html">Audit logging 2</a>
</span>
</li>
<li class="nav-item" data-depth="5">
<span class="nav-line">
<a class="nav-link" href="../../managing/operating/fqllogging.html">Full query logging</a>
</span>
</li>
</ul>
</li>
<li class="nav-item" data-depth="4">
<span class="nav-line">
<a class="nav-link" href="../../managing/operating/metrics.html">Monitoring metrics</a>
</span>
</li>
<li class="nav-item" data-depth="4">
<span class="nav-line">
<a class="nav-link" href="../../managing/operating/repair.html">Repair</a>
</span>
</li>
<li class="nav-item" data-depth="4">
<span class="nav-line">
<a class="nav-link" href="../../managing/operating/read_repair.html">Read repair</a>
</span>
</li>
<li class="nav-item" data-depth="4">
<span class="nav-line">
<a class="nav-link" href="../../managing/operating/security.html">Security</a>
</span>
</li>
<li class="nav-item" data-depth="4">
<span class="nav-line">
<a class="nav-link" href="../../managing/operating/snitch.html">Snitches</a>
</span>
</li>
<li class="nav-item" data-depth="4">
<span class="nav-line">
<a class="nav-link" href="../../managing/operating/topo_changes.html">Topology changes</a>
</span>
</li>
<li class="nav-item" data-depth="4">
<span class="nav-line">
<a class="nav-link" href="../../managing/operating/transientreplication.html">Transient replication</a>
</span>
</li>
<li class="nav-item" data-depth="4">
<span class="nav-line">
<a class="nav-link" href="../../managing/operating/virtualtables.html">Virtual tables</a>
</span>
</li>
</ul>
</li>
<li class="nav-item" data-depth="3">
<span class="nav-line">
<button class="nav-toggle"></button>
<a class="nav-link" href="../../managing/tools/index.html">Tools</a>
</span>
<ul class="nav-list">
<li class="nav-item" data-depth="4">
<span class="nav-line">
<a class="nav-link" href="../../managing/tools/cqlsh.html">cqlsh: the CQL shell</a>
</span>
</li>
<li class="nav-item" data-depth="4">
<span class="nav-line">
<a class="nav-link" href="../../managing/tools/nodetool/nodetool.html">nodetool</a>
</span>
</li>
<li class="nav-item" data-depth="4">
<span class="nav-line">
<a class="nav-link" href="../../managing/tools/sstable/index.html">SSTable tools</a>
</span>
</li>
<li class="nav-item" data-depth="4">
<span class="nav-line">
<a class="nav-link" href="#cassandra:managing/tools/cassandra_stress.adoc">cassandra-stress</a>
</span>
</li>
</ul>
</li>
</ul>
</li>
<li class="nav-item" data-depth="2">
<span class="nav-line">
<button class="nav-toggle"></button>
<a class="nav-link" href="../../troubleshooting/index.html">Troubleshooting</a>
</span>
<ul class="nav-list">
<li class="nav-item" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="../../troubleshooting/finding_nodes.html">Finding misbehaving nodes</a>
</span>
</li>
<li class="nav-item" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="../../troubleshooting/reading_logs.html">Reading Cassandra logs</a>
</span>
</li>
<li class="nav-item" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="../../troubleshooting/use_nodetool.html">Using nodetool</a>
</span>
</li>
<li class="nav-item" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="../../troubleshooting/use_tools.html">Using external tools to deep-dive</a>
</span>
</li>
</ul>
</li>
<li class="nav-item" data-depth="2">
<span class="nav-line">
<button class="nav-toggle"></button>
<a class="nav-link" href="../../reference/index.html">Reference</a>
</span>
<ul class="nav-list">
<li class="nav-item" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="../../reference/cql-commands/alter-table.html">ALTER TABLE</a>
</span>
</li>
<li class="nav-item" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="../../reference/cql-commands/create-index.html">CREATE INDEX</a>
</span>
</li>
<li class="nav-item" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="../../reference/cql-commands/create-custom-index.html">CREATE CUSTOM INDEX</a>
</span>
</li>
<li class="nav-item" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="../../reference/cql-commands/create-table.html">CREATE TABLE</a>
</span>
</li>
<li class="nav-item" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="../../reference/cql-commands/drop-index.html">DROP INDEX</a>
</span>
</li>
<li class="nav-item" data-depth="3">
<span class="nav-line">
<a class="nav-link" href="../../reference/cql-commands/drop-table.html">DROP TABLE</a>
</span>
</li>
</ul>
</li>
<li class="nav-item" data-depth="2">
<span class="nav-line">
<a class="nav-link" href="../../integrating/plugins/index.html">Plug-ins</a>
</span>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</nav>
<aside class="toc sidebar">
<div class="toc-menu"></div>
</aside>
<main class="article default-main full-800" data-ceiling="topbar">
<div class="article-banner">
<p>You are viewing the documentation for a prerelease version.</p>
</div>
<div class="article-header">
<nav class="crumbs" aria-label="breadcrumbs">
<ul>
<li class="crumb">Cassandra</li>
<li class="crumb"><a href="index.html">Cassandra Query Language (CQL)</a></li>
<li class="crumb"><a href="ddl.html">Data definition (DDL)</a></li>
</ul>
</nav>
<div class="tools" role="navigation">
<ul>
<li class="tool edit"><a href="https://github.com/apache/cassandra/edit/cassandra-5.0/doc/modules/cassandra/pages/developing/cql/ddl.adoc" title="Edit Page" target="_blank" rel="noopener">Edit</a></li>
</ul>
</div>
</div>
<article class="doc">
<h1 class="page">Data Definition</h1>
<div id="preamble">
<div class="sectionbody">
<div class="paragraph">
<p>CQL stores data in <em>tables</em>, whose schema defines the layout of the
data in the table. Tables are located in <em>keyspaces</em>.
A keyspace defines options that apply to all the keyspace&#8217;s tables.
The <a href="#replication-strategy">replication strategy</a>
is an important keyspace option, as is the replication factor.
A good general rule is one keyspace per application.
It is common for a cluster to define only one keyspace for an active application.</p>
</div>
<div class="paragraph">
<p>This section describes the statements used to create, modify, and remove
those keyspace and tables.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="common-definitions"><a class="anchor" href="#common-definitions"></a>Common definitions</h2>
<div class="sectionbody">
<div class="paragraph">
<p>The names of the keyspaces and tables are defined by the following
grammar:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bnf hljs" data-lang="bnf">keyspace_name::= name
table_name::= [keyspace_name '.' ] name
name::= unquoted_name | quoted_name
unquoted_name::= re('[a-zA-Z_0-9]\{1, 48}')
quoted_name::= '"' unquoted_name '"'</code></pre>
</div>
</div>
<div class="paragraph">
<p>Both keyspace and table name should be comprised of only alphanumeric
characters, cannot be empty and are limited in size to 48 characters
(that limit exists mostly to avoid filenames (which may include the
keyspace and table name) to go over the limits of certain file systems).
By default, keyspace and table names are case-insensitive (<code>myTable</code> is
equivalent to <code>mytable</code>) but case sensitivity can be forced by using
double-quotes (<code>"myTable"</code> is different from <code>mytable</code>).</p>
</div>
<div class="paragraph">
<p>Further, a table is always part of a keyspace and a table name can be
provided fully-qualified by the keyspace it is part of. If is is not
fully-qualified, the table is assumed to be in the <em>current</em> keyspace
(see <a href="#use-statement">USE</a> statement).</p>
</div>
<div class="paragraph">
<p>Further, the valid names for columns are defined as:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bnf hljs" data-lang="bnf">column_name::= identifier</code></pre>
</div>
</div>
<div class="paragraph">
<p>We also define the notion of statement options for use in the following
section:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bnf hljs" data-lang="bnf">options::= option ( AND option )*
option::= identifier '=' ( identifier
| constant
| map_literal )</code></pre>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="create-keyspace-statement"><a class="anchor" href="#create-keyspace-statement"></a>CREATE KEYSPACE</h2>
<div class="sectionbody">
<div class="paragraph">
<p>A keyspace is created with a <code>CREATE KEYSPACE</code> statement:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bnf hljs" data-lang="bnf">create_keyspace_statement::= CREATE KEYSPACE [ IF NOT EXISTS ] keyspace_name
WITH options</code></pre>
</div>
</div>
<div class="paragraph">
<p>For example:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-cql hljs" data-lang="cql">CREATE KEYSPACE excelsior
WITH replication = {'class': 'SimpleStrategy', 'replication_factor' : 3};
CREATE KEYSPACE excalibur
WITH replication = {'class': 'NetworkTopologyStrategy', 'DC1' : 1, 'DC2' : 3}
AND durable_writes = false;</code></pre>
</div>
</div>
<div class="paragraph">
<p>Attempting to create a keyspace that already exists will return an error
unless the <code>IF NOT EXISTS</code> option is used. If it is used, the statement
will be a no-op if the keyspace already exists.</p>
</div>
<div class="paragraph">
<p>The supported <code>options</code> are:</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 20%;">
<col style="width: 20%;">
<col style="width: 20%;">
<col style="width: 20%;">
<col style="width: 20%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">name</th>
<th class="tableblock halign-left valign-top">kind</th>
<th class="tableblock halign-left valign-top">mandatory</th>
<th class="tableblock halign-left valign-top">default</th>
<th class="tableblock halign-left valign-top">description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>replication</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>map</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">yes</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">n/a</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The replication strategy and options to use for the keyspace (see
details below).</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>durable_writes</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>simple</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">no</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">true</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Whether to use the commit log for updates on this keyspace (disable this
option at your own risk!).</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>The <code>replication</code> property is mandatory and must contain the <code>'class'</code> sub-option that defines the desired
<a href="#replication-strategy">replication strategy</a> class.
The rest of the sub-options depend on which replication strategy is used.
By default, Cassandra supports the following <code>'class'</code> values:</p>
</div>
<div class="sect2">
<h3 id="replication-strategy"><a class="anchor" href="#replication-strategy"></a><code>SimpleStrategy</code></h3>
<div class="paragraph">
<p>A simple strategy that defines a replication factor for data to be
spread across the entire cluster. This is generally not a wise choice
for production, as it does not respect datacenter layouts and can
lead to wildly varying query latency. For production, use
<code>NetworkTopologyStrategy</code>. <code>SimpleStrategy</code> supports a single
mandatory argument:</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 25%;">
<col style="width: 25%;">
<col style="width: 25%;">
<col style="width: 25%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">sub-option</th>
<th class="tableblock halign-left valign-top">type</th>
<th class="tableblock halign-left valign-top">since</th>
<th class="tableblock halign-left valign-top">description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>'replication_factor'</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">int</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">all</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The number of replicas to store per range</p></td>
</tr>
</tbody>
</table>
</div>
<div class="sect2">
<h3 id="networktopologystrategy"><a class="anchor" href="#networktopologystrategy"></a><code>NetworkTopologyStrategy</code></h3>
<div class="paragraph">
<p>A production-ready replication strategy that sets the
replication factor independently for each data-center. The rest of the
sub-options are key-value pairs, with a key set to a data-center name and
its value set to the associated replication factor. Options:</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 25%;">
<col style="width: 25%;">
<col style="width: 25%;">
<col style="width: 25%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">sub-option</th>
<th class="tableblock halign-left valign-top">type</th>
<th class="tableblock halign-left valign-top">description</th>
<th class="tableblock halign-left valign-top"><code>'&lt;datacenter&gt;'</code></th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">int</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The number of replicas to store per range in the provided datacenter.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>'replication_factor'</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">int</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>When later altering keyspaces and changing the <code>replication_factor</code>,
auto-expansion will only <em>add</em> new datacenters for safety, it will not
alter existing datacenters or remove any, even if they are no longer in
the cluster. If you want to remove datacenters while setting the
<code>replication_factor</code>, explicitly zero out the datacenter you want to
have zero replicas.</p>
</div>
<div class="paragraph">
<p>An example of auto-expanding datacenters with two datacenters: <code>DC1</code> and
<code>DC2</code>:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-cql hljs" data-lang="cql">CREATE KEYSPACE excalibur
WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor' : 3};
DESCRIBE KEYSPACE excalibur;</code></pre>
</div>
</div>
<div class="paragraph">
<p>will result in:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-plaintext hljs" data-lang="plaintext">CREATE KEYSPACE excalibur WITH replication = {'class': 'NetworkTopologyStrategy', 'DC1': '3', 'DC2': '3'} AND durable_writes = true;</code></pre>
</div>
</div>
<div class="paragraph">
<p>An example of auto-expanding and overriding a datacenter:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-cql hljs" data-lang="cql">CREATE KEYSPACE excalibur
WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor' : 3, 'DC2': 2};
DESCRIBE KEYSPACE excalibur;</code></pre>
</div>
</div>
<div class="paragraph">
<p>will result in:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-plaintext hljs" data-lang="plaintext">CREATE KEYSPACE excalibur WITH replication = {'class': 'NetworkTopologyStrategy', 'DC1': '3', 'DC2': '2'} AND durable_writes = true;</code></pre>
</div>
</div>
<div class="paragraph">
<p>An example that excludes a datacenter while using <code>replication_factor</code>:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-cql hljs" data-lang="cql">CREATE KEYSPACE excalibur
WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor' : 3, 'DC2': 0};
DESCRIBE KEYSPACE excalibur;</code></pre>
</div>
</div>
<div class="paragraph">
<p>will result in:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-plaintext hljs" data-lang="plaintext">CREATE KEYSPACE excalibur WITH replication = {'class': 'NetworkTopologyStrategy', 'DC1': '3'} AND durable_writes = true;</code></pre>
</div>
</div>
<div class="paragraph">
<p>If <a href="#new/transientreplication.adoc" class="page unresolved">transient replication</a> has been enabled, transient replicas can be
configured for both <code>SimpleStrategy</code> and <code>NetworkTopologyStrategy</code> by
defining replication factors in the format
<code>'&lt;total_replicas&gt;/&lt;transient_replicas&gt;'</code></p>
</div>
<div class="paragraph">
<p>For instance, this keyspace will have 3 replicas in DC1, 1 of which is
transient, and 5 replicas in DC2, 2 of which are transient:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-cql hljs" data-lang="cql">CREATE KEYSPACE some_keyspace
WITH replication = {'class': 'NetworkTopologyStrategy', 'DC1' : '3/1'', 'DC2' : '5/2'};</code></pre>
</div>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="use-statement"><a class="anchor" href="#use-statement"></a>USE</h2>
<div class="sectionbody">
<div class="paragraph">
<p>The <code>USE</code> statement changes the <em>current</em> keyspace to the specified keyspace.
A number of objects in CQL are bound to a keyspace (tables, user-defined types, functions, etc.) and the
current keyspace is the default keyspace used when those objects are
referred to in a query without a fully-qualified name (without a prefixed keyspace name).
A <code>USE</code> statement specifies the keyspace to use as an argument:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bnf hljs" data-lang="bnf">use_statement::= USE keyspace_name</code></pre>
</div>
</div>
<div class="paragraph">
<p>Using CQL:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-cql hljs" data-lang="cql">USE excelsior;</code></pre>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="alter-keyspace-statement"><a class="anchor" href="#alter-keyspace-statement"></a>ALTER KEYSPACE</h2>
<div class="sectionbody">
<div class="paragraph">
<p>An <code>ALTER KEYSPACE</code> statement modifies the options of a keyspace:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bnf hljs" data-lang="bnf">alter_keyspace_statement::= ALTER KEYSPACE [ IF EXISTS ] keyspace_name
WITH options</code></pre>
</div>
</div>
<div class="paragraph">
<p>For example:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-cql hljs" data-lang="cql">ALTER KEYSPACE excelsior
WITH replication = {'class': 'SimpleStrategy', 'replication_factor' : 4};</code></pre>
</div>
</div>
<div class="paragraph">
<p>If the keyspace does not exist, the statement will return an error, unless <code>IF EXISTS</code> is used in which case the operation is a no-op.
The supported options are the same as for <a href="#create-keyspace-statement">creating a keyspace</a>.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="drop-keyspace-statement"><a class="anchor" href="#drop-keyspace-statement"></a>DROP KEYSPACE</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Dropping a keyspace is done with the <code>DROP KEYSPACE</code> statement:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bnf hljs" data-lang="bnf">drop_keyspace_statement::= DROP KEYSPACE [ IF EXISTS ] keyspace_name</code></pre>
</div>
</div>
<div class="paragraph">
<p>For example:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-cql hljs" data-lang="cql">DROP KEYSPACE excelsior;</code></pre>
</div>
</div>
<div class="paragraph">
<p>Dropping a keyspace results in the immediate, irreversible removal of
that keyspace, including all the tables, user-defined types, user-defined functions, and
all the data contained in those tables.</p>
</div>
<div class="paragraph">
<p>If the keyspace does not exists, the statement will return an error,
unless <code>IF EXISTS</code> is used in which case the operation is a no-op.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="create-table-statement"><a class="anchor" href="#create-table-statement"></a>CREATE TABLE</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Creating a new table uses the <code>CREATE TABLE</code> statement:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bnf hljs" data-lang="bnf">create_table_statement::= CREATE TABLE [ IF NOT EXISTS ] table_name '('
column_definition ( ',' column_definition )*
[ ',' PRIMARY KEY '(' primary_key ')' ]
')' [ WITH table_options ]
column_definition::= column_name cql_type [ STATIC ] [ column_mask ] [ PRIMARY KEY]
column_mask::= MASKED WITH ( DEFAULT | function_name '(' term ( ',' term )* ')' )
primary_key::= partition_key [ ',' clustering_columns ]
partition_key::= column_name | '(' column_name ( ',' column_name )* ')'
clustering_columns::= column_name ( ',' column_name )*
table_options::= COMPACT STORAGE [ AND table_options ]
| CLUSTERING ORDER BY '(' clustering_order ')'
[ AND table_options ] | options
clustering_order::= column_name (ASC | DESC) ( ',' column_name (ASC | DESC) )*</code></pre>
</div>
</div>
<div class="paragraph">
<p>For example, here are some CQL statements to create tables:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-cql hljs" data-lang="cql">CREATE TABLE monkey_species (
species text PRIMARY KEY,
common_name text,
population varint,
average_size int
) WITH comment='Important biological records';
CREATE TABLE timeline (
userid uuid,
posted_month int,
posted_time uuid,
body text,
posted_by text,
PRIMARY KEY (userid, posted_month, posted_time)
) WITH compaction = { 'class' : 'LeveledCompactionStrategy' };
CREATE TABLE loads (
machine inet,
cpu int,
mtime timeuuid,
load float,
PRIMARY KEY ((machine, cpu), mtime)
) WITH CLUSTERING ORDER BY (mtime DESC);</code></pre>
</div>
</div>
<div class="paragraph">
<p>A CQL table has a name and is composed of a set of <em>rows</em>.
Creating a table amounts to defining which <a href="#column-definition">columns</a> each rows will have,
which of those columns comprise the <a href="#primary-key">primary key</a>, as well as defined
<a href="#create-table-options">options</a> for the table.</p>
</div>
<div class="paragraph">
<p>Attempting to create an already existing table will return an error
unless the <code>IF NOT EXISTS</code> directive is used. If it is used, the
statement will be a no-op if the table already exists.</p>
</div>
<div class="sect2">
<h3 id="column-definition"><a class="anchor" href="#column-definition"></a>Column definitions</h3>
<div class="paragraph">
<p>Every row in a CQL table will have the predefined columns defined at table creation.
Columns can be added later using an <a href="#alter-table-statement">alter statement</a>.</p>
</div>
<div class="paragraph">
<p>A <code>column_definition</code> is comprised of the name of the column and its <a href="#data-type">type</a>,
restricting the values that are accepted for that column. Additionally, a column definition can have the
following modifiers:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><code>STATIC</code>: declares the column as a <a href="#static-column">static column</a></p>
</li>
<li>
<p><code>PRIMARY KEY</code>: declares the column as the sole component of the <a href="#primary-key">primary key</a> of the table</p>
</li>
</ul>
</div>
<div class="sect3">
<h4 id="static-column"><a class="anchor" href="#static-column"></a>Static columns</h4>
<div class="paragraph">
<p>Some columns can be declared as <code>STATIC</code> in a table definition. A column
that is static will be “shared” by all the rows belonging to the same
partition (having the same <a href="#partition-key">partition key</a>.</p>
</div>
<div class="paragraph">
<p>For example:</p>
</div>
<div class="tabset is-loading">
<div class="ulist tabs">
<ul>
<li>
<p><a id="tabset1_code"></a>Code</p>
</li>
<li>
<p><a id="tabset1_results"></a>Results</p>
</li>
</ul>
</div>
<div class="content">
<div class="tab-pane" aria-labelledby="tabset1_code">
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-cql hljs" data-lang="cql">CREATE TABLE t (
pk int,
t int,
v text,
s text static,
PRIMARY KEY (pk, t)
);
INSERT INTO t (pk, t, v, s) VALUES (0, 0, 'val0', 'static0');
INSERT INTO t (pk, t, v, s) VALUES (0, 1, 'val1', 'static1');
SELECT * FROM t;</code></pre>
</div>
</div>
</div>
<div class="tab-pane" aria-labelledby="tabset1_results">
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-cql hljs" data-lang="cql"> pk | t | v | s
----+---+--------+-----------
0 | 0 | 'val0' | 'static1'
0 | 1 | 'val1' | 'static1'</code></pre>
</div>
</div>
</div>
</div>
</div>
<div class="paragraph">
<p>As can be seen, the <code>s</code> value is the same (<code>static1</code>) for both of the
rows in the partition (the partition key being <code>pk</code>, and both
rows are in the same partition): the second insertion overrides the
value for <code>s</code>.</p>
</div>
<div class="paragraph">
<p>The use of static columns has the following restrictions:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>A table without clustering columns cannot have static columns.
In a table without clustering columns, every partition has only one row, and
so every column is inherently static)</p>
</li>
<li>
<p>Only non-primary key columns can be static.</p>
</li>
</ul>
</div>
</div>
</div>
<div class="sect2">
<h3 id="primary-key"><a class="anchor" href="#primary-key"></a>The Primary key</h3>
<div class="paragraph">
<p>Within a table, a row is uniquely identified by its <code>PRIMARY KEY</code>, and
hence all tables <strong>must</strong> define a single PRIMARY KEY.
A <code>PRIMARY KEY</code> is composed of one or more of the defined columns in the table.
Syntactically, the primary key is defined with the phrase <code>PRIMARY KEY</code>
followed by a comma-separated list of the column names within parenthesis.
If the primary key has only one column, you can alternatively add the <code>PRIMARY KEY</code> phrase to
that column in the table definition.
The order of the columns in the primary key definition defines the partition key and
clustering columns.</p>
</div>
<div class="paragraph">
<p>A CQL primary key is composed of two parts:</p>
</div>
<div class="dlist">
<dl>
<dt class="hdlist1"><a href="#partition-key">partition key</a></dt>
<dd>
<div class="ulist">
<ul>
<li>
<p>It is the first component of the primary key definition.
It can be a single column or, using an additional set of parenthesis, can be multiple columns.
A table must have at least one partition key, the smallest possible table definition is:</p>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-cql hljs" data-lang="cql">CREATE TABLE t (k text PRIMARY KEY);</code></pre>
</div>
</div>
</li>
</ul>
</div>
</dd>
<dt class="hdlist1"><a href="#clustering-columns">clustering columns</a></dt>
<dd>
<div class="ulist">
<ul>
<li>
<p>The columns are the columns that follow the partition key in the primary key definition.
The order of those columns define the <em>clustering order</em>.</p>
</li>
</ul>
</div>
</dd>
</dl>
</div>
<div class="paragraph">
<p>Some examples of primary key definition are:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><code>PRIMARY KEY (a)</code>: <code>a</code> is the single partition key and there are no clustering columns</p>
</li>
<li>
<p><code>PRIMARY KEY (a, b, c)</code> : <code>a</code> is the single partition key and <code>b</code> and <code>c</code> are the clustering columns</p>
</li>
<li>
<p><code>PRIMARY KEY ((a, b), c)</code> : <code>a</code> and <code>b</code> compose the <em>composite</em> partition key and <code>c</code> is the clustering column</p>
</li>
</ul>
</div>
<div class="admonitionblock important">
<table>
<tr>
<td class="icon">
<i class="fa icon-important" title="Important"></i>
</td>
<td class="content">
<div class="paragraph">
<p>The primary key uniquely identifies a row in the table, as described above.
A consequence of this uniqueness is that if another row is inserted using the same primary key,
then an <code>UPSERT</code> occurs and an existing row with the same primary key is replaced.
Columns that are not part of the primary key cannot define uniqueness.</p>
</div>
</td>
</tr>
</table>
</div>
<div class="sect3">
<h4 id="partition-key"><a class="anchor" href="#partition-key"></a>Partition key</h4>
<div class="paragraph">
<p>Within a table, CQL defines the notion of a <em>partition</em> that defines the location of data within a Cassandra cluster.
A partition is the set of rows that share the same value for their partition key.</p>
</div>
<div class="paragraph">
<p>Note that if the partition key is composed of multiple columns, then rows belong to the same partition
when they have the same values for all those partition key columns.
A hash is computed from the partition key columns and that hash value defines the partition location.
So, for instance, given the following table definition and content:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-cql hljs" data-lang="cql">CREATE TABLE t (
a int,
b int,
c int,
d int,
PRIMARY KEY ((a, b), c, d)
);
INSERT INTO t (a, b, c, d) VALUES (0,0,0,0);
INSERT INTO t (a, b, c, d) VALUES (0,0,1,1);
INSERT INTO t (a, b, c, d) VALUES (0,1,2,2);
INSERT INTO t (a, b, c, d) VALUES (0,1,3,3);
INSERT INTO t (a, b, c, d) VALUES (1,1,4,4);
SELECT * FROM t;</code></pre>
</div>
</div>
<div class="paragraph">
<p>will result in</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-cql hljs" data-lang="cql"> a | b | c | d
---+---+---+---
0 | 0 | 0 | 0 <i class="conum" data-value="1"></i><b>(1)</b>
0 | 0 | 1 | 1
0 | 1 | 2 | 2 <i class="conum" data-value="2"></i><b>(2)</b>
0 | 1 | 3 | 3
1 | 1 | 4 | 4 <i class="conum" data-value="3"></i><b>(3)</b>
(5 rows)</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>Rows 1 and 2 are in the same partition, because both columns <code>a</code> and <code>b</code> are zero.</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>Rows 3 and 4 are in the same partition, but a different one, because column <code>a</code> is zero and column <code>b</code> is 1 in both rows.</td>
</tr>
<tr>
<td><i class="conum" data-value="3"></i><b>3</b></td>
<td>Row 5 is in a third partition by itself, because both columns <code>a</code> and <code>b</code> are 1.</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>Note that a table always has a partition key, and that if the table has
no <code>clustering columns</code>, then every partition of that table has a single row.
because the partition key, compound or otherwise, identifies a single location.</p>
</div>
<div class="paragraph">
<p>The most important property of partition is that all the rows belonging
to the same partition are guaranteed to be stored on the same set of
replica nodes.
In other words, the partition key of a table defines which rows will be localized on the same
node in the cluster.
The localization of data is important to the efficient retrieval of data, requiring the Cassandra coordinator
to contact as few nodes as possible.
However, there is a flip-side to this guarantee, and all rows sharing a partition key will be stored on the same
node, creating a hotspot for both reading and writing.
While selecting a primary key that groups table rows assists batch updates and can ensure that the updates are
<em>atomic</em> and done in <em>isolation</em>, the partitions must be sized "just right, not too big nor too small".</p>
</div>
<div class="paragraph">
<p>Data modeling that considers the querying patterns and assigns primary keys based on the queries will have the lowest
latency in fetching data.</p>
</div>
</div>
<div class="sect3">
<h4 id="clustering-columns"><a class="anchor" href="#clustering-columns"></a>Clustering columns</h4>
<div class="paragraph">
<p>The clustering columns of a table define the clustering order for the partition of that table.
For a given <code>partition</code>, all rows are ordered by that clustering order. Clustering columns also add uniqueness to
a row in a table.</p>
</div>
<div class="paragraph">
<p>For instance, given:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-cql hljs" data-lang="cql">CREATE TABLE t2 (
a int,
b int,
c int,
d int,
PRIMARY KEY (a, b, c)
);
INSERT INTO t2 (a, b, c, d) VALUES (0,0,0,0);
INSERT INTO t2 (a, b, c, d) VALUES (0,0,1,1);
INSERT INTO t2 (a, b, c, d) VALUES (0,1,2,2);
INSERT INTO t2 (a, b, c, d) VALUES (0,1,3,3);
INSERT INTO t2 (a, b, c, d) VALUES (1,1,4,4);
SELECT * FROM t2;</code></pre>
</div>
</div>
<div class="paragraph">
<p>will result in</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-cql hljs" data-lang="cql"> a | b | c | d
---+---+---+---
1 | 1 | 4 | 4 <i class="conum" data-value="1"></i><b>(1)</b>
0 | 0 | 0 | 0
0 | 0 | 1 | 1
0 | 1 | 2 | 2
0 | 1 | 3 | 3
(5 rows)</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>Row 1 is in one partition, and Rows 2-5 are in a different one. The display order is also different.</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>Looking more closely at the four rows in the same partition, the <code>b</code> clustering column defines the order in which those rows
are displayed.
Whereas the partition key of the table groups rows on the same node, the clustering columns control
how those rows are stored on the node.</p>
</div>
<div class="paragraph">
<p>That sorting allows the very efficient retrieval of a range of rows within a partition:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-cql hljs" data-lang="cql">SELECT * FROM t2 WHERE a = 0 AND b &gt; 0 and b &lt;= 3;</code></pre>
</div>
</div>
<div class="paragraph">
<p>will result in</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-cql hljs" data-lang="cql"> a | b | c | d
---+---+---+---
0 | 1 | 2 | 2
0 | 1 | 3 | 3
(2 rows)</code></pre>
</div>
</div>
</div>
</div>
<div class="sect2">
<h3 id="create-table-options"><a class="anchor" href="#create-table-options"></a>Table options</h3>
<div class="paragraph">
<p>A CQL table has a number of options that can be set at creation (and,
for most of them, altered later). These options are specified after the
<code>WITH</code> keyword.</p>
</div>
<div class="paragraph">
<p>One important option that cannot be changed after creation, <code>CLUSTERING ORDER BY</code>, influences how queries can be done against the table. It is worth discussing in more detail here.</p>
</div>
<div class="sect3">
<h4 id="clustering-order"><a class="anchor" href="#clustering-order"></a>Clustering order</h4>
<div class="paragraph">
<p>The clustering order of a table is defined by the clustering columns.
By default, the clustering order is ascending for the clustering column&#8217;s data types.
For example, integers order from 1, 2, &#8230;&#8203; n, while text orders from A to Z.</p>
</div>
<div class="paragraph">
<p>The <code>CLUSTERING ORDER BY</code> table option uses a comma-separated list of the
clustering columns, each set for either <code>ASC</code> (for <em>ascending</em> order) or <code>DESC</code> (for _descending order).
The default is ascending for all clustering columns if the <code>CLUSTERING ORDER BY</code> option is not set.</p>
</div>
<div class="paragraph">
<p>This option is basically a hint for the storage engine that changes the order in which it stores the row.
Beware of the consequences of setting this option:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>It changes the default ascending order of results when queried with a <code>SELECT</code> statement with no <code>ORDER BY</code> clause.</p>
</li>
<li>
<p>It limits how the <code>ORDER BY</code> clause is used in <code>SELECT</code> statements on that table.
Results can only be ordered with either the original clustering order or the reverse clustering order.
Suppose you create a table with two clustering columns <code>a</code> and <code>b</code>, defined <code>WITH CLUSTERING ORDER BY (a DESC, b ASC)</code>.
Queries on the table can use <code>ORDER BY (a DESC, b ASC)</code> or <code>ORDER BY (a ASC, b DESC)</code>.
Mixed order, such as <code>ORDER BY (a ASC, b ASC)</code> or <code>ORDER BY (a DESC, b DESC)</code> will not return expected order.</p>
</li>
<li>
<p>It has a performance impact on queries. Queries in reverse clustering order are slower than the default ascending order.
If you plan to query mostly in descending order, declare the clustering order in the table schema using <code>WITH CLUSTERING ORDER BY ()</code>.
This optimization is common for time series, to retrieve the data from newest to oldest.</p>
</li>
</ul>
</div>
</div>
<div class="sect3">
<h4 id="create-table-general-options"><a class="anchor" href="#create-table-general-options"></a>Other table options</h4>
<div class="paragraph">
<p>A table supports the following options:</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 30%;">
<col style="width: 9%;">
<col style="width: 11%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">option</th>
<th class="tableblock halign-left valign-top">kind</th>
<th class="tableblock halign-left valign-top">default</th>
<th class="tableblock halign-left valign-top">description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>comment</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>simple</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">none</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A free-form, human-readable comment</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#spec_retry"><code>speculative_retry</code></a></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>simple</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">99PERCENTILE</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Speculative retry options</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>cdc</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>boolean</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Create a Change Data Capture (CDC) log on the table</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>additional_write_policy</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>simple</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">99PERCENTILE</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Same as <code>speculative_retry</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>gc_grace_seconds</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>simple</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">864000</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Time to wait before garbage collecting tombstones (deletion markers)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>bloom_filter_fp_chance</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>simple</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0.00075</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The target probability of
false positive of the sstable bloom filters. Said bloom filters will be
sized to provide the provided probability, thus lowering this value
impacts the size of bloom filters in-memory and on-disk.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>default_time_to_live</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>simple</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Default expiration time (“TTL”) in seconds for a table</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>compaction</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>map</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>see below</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="../../managing/operating/compaction/index.html#cql-compaction-options" class="page">Compaction options</a></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>compression</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>map</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>see below</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#cassandra:managing/operating/compression/index.adoc#cql-compression-options" class="page unresolved">Compression options</a></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>caching</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>map</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>see below</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Caching options</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>memtable_flush_period_in_ms</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>simple</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Time (in ms) before Cassandra flushes memtables to disk</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>read_repair</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>simple</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">BLOCKING</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Sets read repair behavior (see below)</p></td>
</tr>
</tbody>
</table>
<div class="sect4">
<h5 id="spec_retry"><a class="anchor" href="#spec_retry"></a>Speculative retry options</h5>
<div class="paragraph">
<p>By default, Cassandra read coordinators only query as many replicas as
necessary to satisfy consistency levels: one for consistency level
<code>ONE</code>, a quorum for <code>QUORUM</code>, and so on. <code>speculative_retry</code> determines
when coordinators may query additional replicas, a useful action when
replicas are slow or unresponsive. Speculative retries reduce the latency.
The speculative_retry option configures rapid read protection, where a coordinator sends more
requests than needed to satisfy the consistency level.</p>
</div>
<div class="admonitionblock important">
<table>
<tr>
<td class="icon">
<i class="fa icon-important" title="Important"></i>
</td>
<td class="content">
<div class="paragraph">
<p>Frequently reading from additional replicas can hurt cluster
performance. When in doubt, keep the default <code>99PERCENTILE</code>.</p>
</div>
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>Pre-Cassandra 4.0 speculative retry policy takes a single string as a parameter:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><code>NONE</code></p>
</li>
<li>
<p><code>ALWAYS</code></p>
</li>
<li>
<p><code>99PERCENTILE</code> (PERCENTILE)</p>
</li>
<li>
<p><code>50MS</code> (CUSTOM)</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>An example of setting speculative retry sets a custom value:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-cql hljs" data-lang="cql">ALTER TABLE users WITH speculative_retry = '10ms';</code></pre>
</div>
</div>
<div class="paragraph">
<p>This example uses a percentile for the setting:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-cql hljs" data-lang="cql">ALTER TABLE users WITH speculative_retry = '99PERCENTILE';</code></pre>
</div>
</div>
<div class="paragraph">
<p>A percentile setting can backfire. If a single host becomes unavailable, it can
force up the percentiles. A value of <code>p99</code> will not speculate as intended because the
value at the specified percentile has increased too much. If the consistency level is set to <code>ALL</code>, all
replicas are queried regardless of the speculative retry setting.</p>
</div>
<div class="paragraph">
<p>Cassandra 4.0 supports case-insensitivity for speculative retry values (<a href="https://issues.apache.org/jira/browse/CASSANDRA-14293">CASSANDRA-14293</a>). For example, assigning the value as <code>none</code>, <code>None</code>, or <code>NONE</code> has the same effect.</p>
</div>
<div class="paragraph">
<p>Additionally, the following values are added:</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 33.3333%;">
<col style="width: 33.3333%;">
<col style="width: 33.3334%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Format</th>
<th class="tableblock halign-left valign-top">Example</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>XPERCENTILE</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">90.5PERCENTILE</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Coordinators record average per-table response times
for all replicas. If a replica takes longer than <code>X</code> percent of this
table&#8217;s average response time, the coordinator queries an additional
replica. <code>X</code> must be between 0 and 100.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>XP</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">90.5P</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Same as <code>XPERCENTILE</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>Yms</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">25ms</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">If a replica takes more than <code>Y</code> milliseconds to respond, the
coordinator queries an additional replica.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>MIN(XPERCENTILE,YMS)</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">MIN(99PERCENTILE,35MS)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A hybrid policy that uses either the
specified percentile or fixed milliseconds depending on which value is
lower at the time of calculation. Parameters are <code>XPERCENTILE</code>, <code>XP</code>, or
<code>Yms</code>. This setting helps protect against a single slow instance.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>MAX(XPERCENTILE,YMS)</code> <code>ALWAYS</code> <code>NEVER</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">MAX(90.5P,25ms)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A hybrid policy that uses either the specified
percentile or fixed milliseconds depending on which value is higher at
the time of calculation.</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>Cassandra 4.0 adds support for hybrid <code>MIN()</code> and <code>MAX()</code> speculative retry policies, with a mix and match of either <code>MIN(), MAX()</code>, <code>MIN(), MIN()</code>, or <code>MAX(), MAX()</code> (<a href="https://issues.apache.org/jira/browse/CASSANDRA-14293">CASSANDRA-14293</a>).
The hybrid mode will still speculate if the normal <code>p99</code> for the table is &lt; 50ms, the minimum value.
But if the <code>p99</code> level goes higher than the maximum value, then that value can be used.
In a hybrid value, one value must be a fixed time (ms) value and the other a percentile value.</p>
</div>
<div class="paragraph">
<p>To illustrate variations, the following examples are all valid:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-cql hljs" data-lang="cql">min(99percentile,50ms)
max(99p,50MS)
MAX(99P,50ms)
MIN(99.9PERCENTILE,50ms)
max(90percentile,100MS)
MAX(100.0PERCENTILE,60ms)</code></pre>
</div>
</div>
<div class="paragraph">
<p>The <code>additional_write_policy</code> setting specifies the threshold at which a cheap
quorum write will be upgraded to include transient replicas.</p>
</div>
</div>
<div class="sect4">
<h5 id="cql-compaction-options"><a class="anchor" href="#cql-compaction-options"></a>Compaction options</h5>
<div class="paragraph">
<p>The <code>compaction</code> options must minimally define the <code>'class'</code> sub-option,
to specify the compaction strategy class to use.
The supported classes are:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><code>'SizeTieredCompactionStrategy'</code>, <a href="../../managing/operating/compaction/stcs.html#stcs" class="page">STCS</a> (Default)</p>
</li>
<li>
<p><code>'LeveledCompactionStrategy'</code>, <a href="../../managing/operating/compaction/lcs.html#lcs" class="page">LCS</a></p>
</li>
<li>
<p><code>'TimeWindowCompactionStrategy'</code>, <a href="../../managing/operating/compaction/twcs.html#twcs" class="page">TWCS</a></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>If a custom strategies is required, specify the full class name as a <a href="definitions.html#constants" class="page">string constant</a>.</p>
</div>
<div class="paragraph">
<p>All default strategies support a number of <a href="../../managing/operating/compaction/index.html#compaction-options" class="page">common options</a>, as well as options specific to the strategy chosen. See the section corresponding to your strategy for details: <a href="../../managing/operating/compaction/stcs.html#stcs_options" class="page">STCS</a>, <a href="../../managing/operating/compaction/lcs.html#lcs_options" class="page">LCS</a>, <a href="../../managing/operating/compaction/twcs.html#twcs_options" class="page">TWCS</a>.</p>
</div>
</div>
<div class="sect4">
<h5 id="cql-compression-options"><a class="anchor" href="#cql-compression-options"></a>Compression options</h5>
<div class="paragraph">
<p>The <code>compression</code> options define if and how the SSTables of the table
are compressed. Compression is configured on a per-table basis as an
optional argument to <code>CREATE TABLE</code> or <code>ALTER TABLE</code>. The following
sub-options are available:</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 33.3333%;">
<col style="width: 33.3333%;">
<col style="width: 33.3334%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Option</th>
<th class="tableblock halign-left valign-top">Default</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>class</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">LZ4Compressor</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The compression algorithm to use. Default compressor are: LZ4Compressor,
SnappyCompressor, DeflateCompressor and ZstdCompressor.
Use <code>'enabled' : false</code> to disable compression.
Custom compressor can be provided by specifying the full class name as a <a href="definitions.html#constants" class="page">string constant</a>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>enabled</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">true</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Enable/disable sstable compression.
If the <code>enabled</code> option is set to <code>false</code>, no other options must be specified.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>chunk_length_in_kb</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">64</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">On disk SSTables are compressed by block (to allow random reads).
This option defines the size (in KB) of said block. See <a href="#chunk_note">note</a> for further information.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>compression_level</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">3</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Compression level. Only applicable for <code>ZstdCompressor</code>.
Accepts values between <code>-131072</code> and <code>22</code>.</p></td>
</tr>
</tbody>
</table>
<div id="chunk_note" class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
<div class="paragraph">
<p>Bigger values may improve the compression rate, but will increase the minimum size of data to be read from
disk for a read.
The default value is an optimal value for compressing tables.
Chunk length must be a power of 2 when computing the chunk number from an uncompressed file offset.
Block size may be adjusted based on read/write access patterns such as:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>How much data is typically requested at once</p>
</li>
<li>
<p>Average size of rows in the table</p>
</li>
</ul>
</div>
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>For instance, to create a table with LZ4Compressor and a <code>chunk_length_in_kb</code> of 4 KB:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-cql hljs" data-lang="cql">CREATE TABLE simple (
id int,
key text,
value text,
PRIMARY KEY (key, value)
) WITH compression = {'class': 'LZ4Compressor', 'chunk_length_in_kb': 4};</code></pre>
</div>
</div>
</div>
<div class="sect4">
<h5 id="cql-caching-options"><a class="anchor" href="#cql-caching-options"></a>Caching options</h5>
<div class="paragraph">
<p>Caching optimizes the use of cache memory of a table. The cached data is
weighed by size and access frequency.
The <code>caching</code> options can configure both the <code>key cache</code> and the <code>row cache</code> for the table.
The following sub-options are available:</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 33.3333%;">
<col style="width: 33.3333%;">
<col style="width: 33.3334%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Option</th>
<th class="tableblock halign-left valign-top">Default</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>keys</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">ALL</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Whether to cache keys (key cache) for this table. Valid values are: <code>ALL</code> and <code>NONE</code>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>rows_per_partition</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">NONE</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The amount of rows to cache per partition (row cache).
If an integer <code>n</code> is specified, the first <code>n</code> queried rows of a partition will be cached.
Valid values are: <code>ALL</code>, to cache all rows of a queried partition, or <code>NONE</code> to disable row caching.</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>For instance, to create a table with both a key cache and 10 rows cached per partition:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-cql hljs" data-lang="cql">CREATE TABLE simple (
id int,
key text,
value text,
PRIMARY KEY (key, value)
) WITH caching = {'keys': 'ALL', 'rows_per_partition': 10};</code></pre>
</div>
</div>
</div>
<div class="sect4">
<h5 id="read-repair-options"><a class="anchor" href="#read-repair-options"></a>Read Repair options</h5>
<div class="paragraph">
<p>The <code>read_repair</code> options configure the read repair behavior, tuning for various performance and consistency behaviors.</p>
</div>
<div class="paragraph">
<p>The values are:</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 33.3333%;">
<col style="width: 33.3333%;">
<col style="width: 33.3334%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Option</th>
<th class="tableblock halign-left valign-top">Default</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>BLOCKING</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">yes</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">If a read repair is triggered, the read blocks writes sent to other replicas until the consistency level is reached by the writes.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>NONE</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">no</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">If set, the coordinator reconciles any differences between replicas, but doesn&#8217;t attempt to repair them.</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>Two consistency properties are affected by read repair behavior.</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Monotonic quorum reads: Monotonic quorum reads
prevents reads from appearing to go back in time in some circumstances.
When monotonic quorum reads are not provided and a write fails to reach
a quorum of replicas, the read values may be visible in one read, and then disappear
in a subsequent read. <code>BLOCKING</code> provides this behavior.</p>
</li>
<li>
<p>Write atomicity: Write atomicity prevents reads
from returning partially-applied writes. Cassandra attempts to provide
partition-level write atomicity, but since only the data covered by a
SELECT statement is repaired by a read repair, read repair can break
write atomicity when data is read at a more granular level than it is
written. For example, read repair can break write atomicity if you write
multiple rows to a clustered partition in a batch, but then select a
single row by specifying the clustering column in a SELECT statement.
<code>NONE</code> provides this behavior.</p>
</li>
</ul>
</div>
</div>
<div class="sect4">
<h5 id="other-considerations"><a class="anchor" href="#other-considerations"></a>Other considerations:</h5>
<div class="ulist">
<ul>
<li>
<p>Adding new columns (see <code>ALTER TABLE</code> below) is a constant time
operation. Thus, there is no need to anticipate future usage while initially creating a table.</p>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="alter-table-statement"><a class="anchor" href="#alter-table-statement"></a>ALTER TABLE</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Altering an existing table uses the <code>ALTER TABLE</code> statement:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bnf hljs" data-lang="bnf">alter_table_statement::= ALTER TABLE [ IF EXISTS ] table_name alter_table_instruction
alter_table_instruction::= ADD [ IF NOT EXISTS ] column_definition ( ',' column_definition)*
| DROP [ IF EXISTS ] column_name ( ',' column_name )*
| RENAME [ IF EXISTS ] column_name to column_name (AND column_name to column_name)*
| ALTER [ IF EXISTS ] column_name ( column_mask | DROP MASKED )
| WITH options
column_definition::= column_name cql_type [ column_mask]
column_mask::= MASKED WITH ( DEFAULT | function_name '(' term ( ',' term )* ')' )</code></pre>
</div>
</div>
<div class="paragraph">
<p>If the table does not exist, the statement will return an error, unless <code>IF EXISTS</code> is used in which case the operation is a no-op.</p>
</div>
<div class="paragraph">
<p>For example:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-cql hljs" data-lang="cql">ALTER TABLE addamsFamily ADD gravesite varchar;
ALTER TABLE addamsFamily
WITH comment = 'A most excellent and useful table';</code></pre>
</div>
</div>
<div class="paragraph">
<p>The <code>ALTER TABLE</code> statement can:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><code>ADD</code> a new column to a table. The primary key of a table cannot ever be altered.
A new column, thus, cannot be part of the primary key.
Adding a column is a constant-time operation based on the amount of data in the table.
If the new column already exists, the statement will return an error, unless <code>IF NOT EXISTS</code> is used in which case the operation is a no-op.</p>
</li>
<li>
<p><code>DROP</code> a column from a table. This command drops both the column and all
its content. Be aware that, while the column becomes immediately
unavailable, its content are removed lazily during compaction. Because of this lazy removal,
the command is a constant-time operation based on the amount of data in the table.
Also, it is important to know that once a column is dropped, a column with the same name can be re-added,
unless the dropped column was a non-frozen column like a collection.
If the dropped column does not already exist, the statement will return an error, unless <code>IF EXISTS</code> is used in which case the operation is a no-op.</p>
</li>
</ul>
</div>
<div class="admonitionblock warning">
<table>
<tr>
<td class="icon">
<i class="fa icon-warning" title="Warning"></i>
</td>
<td class="content">
<div class="title">Warning</div>
<div class="paragraph">
<p>Dropping a column assumes that the timestamps used for the value of this
column are "real" timestamp in microseconds. Using "real" timestamps in
microseconds is the default is and is <strong>strongly</strong> recommended but as
Cassandra allows the client to provide any timestamp on any table, it is
theoretically possible to use another convention. Please be aware that
if you do so, dropping a column will not correctly execute.</p>
</div>
</td>
</tr>
</table>
</div>
<div class="ulist">
<ul>
<li>
<p><code>RENAME</code> a primary key column of a table. Non primary key columns cannot be renamed.
Furthermore, renaming a column to another name which already exists isn&#8217;t allowed.
It&#8217;s important to keep in mind that renamed columns shouldn&#8217;t have dependent seconday indexes.
If the renamed column does not already exist, the statement will return an error, unless <code>IF EXISTS</code> is used in which case the operation is a no-op.</p>
</li>
<li>
<p>Use <code>WITH</code> to change a table option. The <a href="#create-table-options">supported options</a>
are the same as those used when creating a table, with the exception of <code>CLUSTERING ORDER</code>.
However, setting any <code>compaction</code> sub-options will erase <strong>ALL</strong> previous <code>compaction</code> options, so you need to re-specify
all the sub-options you wish to keep. The same is true for <code>compression</code> sub-options.</p>
</li>
</ul>
</div>
</div>
</div>
<div class="sect1">
<h2 id="drop-table-statement"><a class="anchor" href="#drop-table-statement"></a>DROP TABLE</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Dropping a table uses the <code>DROP TABLE</code> statement:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bnf hljs" data-lang="bnf">drop_table_statement::= DROP TABLE [ IF EXISTS ] table_name</code></pre>
</div>
</div>
<div class="paragraph">
<p>Dropping a table results in the immediate, irreversible removal of the
table, including all data it contains.</p>
</div>
<div class="paragraph">
<p>If the table does not exist, the statement will return an error, unless
<code>IF EXISTS</code> is used, when the operation is a no-op.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="truncate-statement"><a class="anchor" href="#truncate-statement"></a>TRUNCATE TABLE</h2>
<div class="sectionbody">
<div class="paragraph">
<p>A table can be truncated using the <code>TRUNCATE</code> statement:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bnf hljs" data-lang="bnf">truncate_statement::= TRUNCATE [ TABLE ] table_name</code></pre>
</div>
</div>
<div class="paragraph">
<p><code>TRUNCATE TABLE foo</code> is the preferred syntax for consistency with other DDL
statements.
However, tables are the only object that can be truncated currently, and the <code>TABLE</code> keyword can be omitted.</p>
</div>
<div class="paragraph">
<p>Truncating a table permanently removes all existing data from the table, but without removing the table itself.</p>
</div>
</div>
</div>
</article>
</main>
</div>
</div>
<footer class="grad grad--two flex-center pb-xlarge">
<div class="inner text-center z2 relative">
<h2 class="white py-small">Get started with Cassandra, fast.</h2>
<a id="footer-cta" href="/_/quickstart.html" class="btn btn--filled ma-medium">Quickstart Guide</a>
</div>
<div class="inner flex flex-distribute-items mt-xlarge z2 relative">
<div class="col-2">
<div id="footer-logo" class="logo logo--footer mb-medium"><img src="../../../../../assets/img/logo-white-r.png" alt="Cassandra Logo"></div>
<p>Apache Cassandra<img src="../../../../../assets/img/registered.svg" alt="®" style="width:18px;"> powers mission-critical deployments with improved performance and unparalleled levels of scale in the cloud.</p>
<div class="footer-social-icons">
<a href="https://twitter.com/cassandra?lang=en" target="_blank"><img src="../../../../../assets/img/twitter-icon-circle-white.svg" alt="twitter icon" width="24"></a>
<a href="https://www.linkedin.com/company/apache-cassandra/" target="_blank"><img src="../../../../../assets/img/LI-In-Bug.png" alt="linked-in icon" width="24"></a>
<a href="https://www.youtube.com/c/PlanetCassandra" target="_blank"><img src="../../../../../assets/img/youtube-icon.png" alt="youtube icon" width="24"></a>
</div>
</div>
<div class="col-2 flex flex-center">
<ul class="columns-2">
<li class="mb-small"><a href="/">Home</a></li>
<li class="mb-small"><a href="/_/cassandra-basics.html">Cassandra Basics</a></li>
<li class="mb-small"><a href="/_/quickstart.html">Quickstart</a></li>
<li class="mb-small"><a href="/_/ecosystem.html">Ecosystem</a></li>
<li class="mb-small"><a href="/doc/latest/">Documentation</a></li>
<li class="mb-small"><a href="/_/community.html">Community</a></li>
<li class="mb-small"><a href="/_/case-studies.html">Case Studies</a></li>
<li class="mb-small"><a href="/_/resources.html">Resources</a></li>
<li class="mb-small"><a href="/_/blog.html">Blog</a></li>
</ul>
</div>
</div>
</footer>
<div class="lower-footer bg-white pa-medium">
<div class="flex flex-row flex-vert-center">
<div class="pr-medium"><img src="../../../../../assets/img//feather-small.png" alt="ASF" width="20"></div>
<div class="pr-medium"><a href="http://www.apache.org/" target="_blank">Foundation</a></div>
<div class="pr-medium"><a href="https://www.apache.org/events/current-event.html" target="_blank">Events</a></div>
<div class="pr-medium"><a href="https://www.apache.org/licenses/" target="_blank">License</a></div>
<div class="pr-medium"><a href="https://www.apache.org/foundation/thanks" target="_blank">Thanks</a></div>
<div class="pr-medium"><a href="https://www.apache.org/security" target="_blank">Security</a></div>
<div class="pr-medium"><a href="https://privacy.apache.org/policies/privacy-policy-public.html" target="_blank">Privacy</a></div>
<div class="pr-medium"><a href="https://www.apache.org/foundation/sponsorship" target="_blank">Sponsorship</a></div>
</div>
<p class="my-medium">© 2009-<script>document.write(new Date().getFullYear())</script> <a href="https://apache.org" target="_blank">The Apache Software Foundation</a> under the terms of the Apache License 2.0. Apache, the Apache feather logo, Apache Cassandra, Cassandra, and the Cassandra logo, are either registered trademarks or trademarks of The Apache Software Foundation.</p>
</div>
<div id="fade" class="hidden"></div>
<div id="modal" class="hidden">
<div id="close-modal" class="cursor-pointer"><svg viewBox="0 0 24 24" width="24" height="24" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round" class="css-i6dzq1"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg></div>
<div id="mod-content" class="vid-mod-content resp-container"></div>
</div>
<script src="../../../../../assets/js/site.js"></script>
<script async src="../../../../../assets/js/vendor/highlight.js"></script>
<script src="../../../../../assets/js/vendor/lunr.js"></script>
<script src="../../../../../assets/js/vendor/search.js" id="search-script" data-base-path="../../../../.." data-page-path="/Cassandra/5.0/cassandra/developing/cql/ddl.html"></script>
<script async src="../../../../../assets/../search-index.js"></script>
<script>
jQuery(function(){
var windowW = $(window).width();
$(document)
.on('click','.mobile-nav-icon',function(){
$('.main-nav').fadeIn();
})
.on('click','.main-nav',function(){
if(windowW <= 1000){
$(this).fadeOut();
}
})
.on('click','#version-toggle',function(){
$(this).toggleClass('active');
$(this).next().fadeToggle();
})
.on('click','#mobile-docs-nav-burger', function(){
$(this).toggleClass('active');
$('.docs-nav').toggleClass('active');
});
var url = window.location.pathname;
var isQuickstart = url.includes('quickstart.html');
if(isQuickstart){
var footerCTA = document.getElementById('footer-cta');
footerCTA.innerHTML = 'Get latest updates';
footerCTA.setAttribute('href', '/_/blog.html');
}
});
</script>
</div>
</body>
</html>