

{"id":16611,"date":"2018-05-26T07:30:27","date_gmt":"2018-05-26T07:30:27","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=16611"},"modified":"2021-04-05T13:45:31","modified_gmt":"2021-04-05T08:15:31","slug":"data-definition-command-cql","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/data-definition-command-cql\/","title":{"rendered":"Data Definition Command &#8211; Cassandra Query Language"},"content":{"rendered":"<h2 class=\"western\">1. Objective<\/h2>\n<p><span style=\"font-family: Celibri\"><span style=\"font-size: medium\"><span style=\"color: #121214\">In our last tutorial, we studied\u00a0<strong><a href=\"https:\/\/data-flair.training\/blogs\/cassandra-shell-commands\/\">10 Cassandra Shell Commands<\/a>\u00a0<\/strong>and in this <a href=\"https:\/\/data-flair.training\/blogs\/apache-cassandra-tutorial\/\"><strong>Cassandra Tutorial<\/strong><\/a>, we will deal with the <em>Data Definition Command<\/em>\u00a0in CQL. <\/span><\/span><\/span><\/p>\n<p><span style=\"font-family: Celibri\"><span style=\"font-size: medium\"><span style=\"color: #121214\">Moreover, we will discuss keyspace in Cassandra and its various commands like\u00a0Create Keyspace, Use, Alter Keyspace, Drop Keyspace, Create Table, Alter Table, Truncate Table, Drop Table,\u00a0 Create Index, and Drop Index. In addition, we will discuss each command with their syntax &amp; example. <\/span><\/span><\/span><\/p>\n<p><span style=\"font-family: Celibri\"><span style=\"font-size: medium\"><span style=\"color: #121214\">So, let&#8217;s start Data Definition command &#8211; CQL.<\/span><\/span><\/span><\/p>\n<div id=\"attachment_16629\" style=\"width: 1210px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/data-definition-command-01.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-16629\" class=\"wp-image-16629 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/data-definition-command-01.jpg\" alt=\"Data Definition Command - Cassandra Query Language\" width=\"1200\" height=\"628\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/data-definition-command-01.jpg 1200w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/data-definition-command-01-150x79.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/data-definition-command-01-300x157.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/data-definition-command-01-768x402.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/data-definition-command-01-1024x536.jpg 1024w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/a><p id=\"caption-attachment-16629\" class=\"wp-caption-text\">Data Definition Command &#8211; Cassandra Query Language<\/p><\/div>\n<p><strong><a href=\"https:\/\/data-flair.training\/blogs\/cassandra-terminologies\/\">Do you know top Cassandra Terminologies<\/a><\/strong><\/p>\n<h2>2. CQL &#8211; Data Definition Command<\/h2>\n<p><span style=\"font-family: Celibri\"><span style=\"font-size: medium\"><span style=\"color: #121214\">Data definition command are used for defining the data in the database. They are another type of commands used in cqlsh prompt. In other words, they are used to create data and data storage units in the database. These commands basically are used to create and manipulate keyspace, table,\u00a0<\/span><\/span><\/span><span style=\"color: #121214;font-size: medium;font-family: Celibri;font-weight: inherit\">and index.<\/span><\/p>\n<h2>3. Cassandra Keyspace<\/h2>\n<p><span style=\"font-family: Celibri\"><span style=\"font-size: medium\"><span style=\"color: #121214\">In Cassandra Data definition Command, Keyspace is basically a namespace that defines data replication on nodes. There are many clusters in a Cassandra database. Every Cassandra cluster contains one keyspace per node. This keyspace is created and altered using Data Definition Command.<\/span><\/span><\/span><br \/>\n<strong><a href=\"https:\/\/data-flair.training\/blogs\/hbase-vs-cassandra\/\">Do you know\u00a0 Major Difference &amp; Similarities Between\u00a0HBase vs Cassandra<\/a><\/strong><\/p>\n<h3>a. Create Keyspace<\/h3>\n<p><span style=\"font-family: Celibri\"><span style=\"font-size: medium\"><span style=\"color: #121214\">This command is used to create a keyspace. Every system specifies a node. This system or node has a keyspace. This keyspace is a storage unit for the data. Data definition command help to create keyspace.<br \/>\n<strong>SYNTAX:<\/strong><\/span><\/span><\/span><\/p>\n<pre class=\"EnlighterJSRAW\">CREATE KEYSPACE &lt;keyspace name&gt; WITH &lt;properties&gt; AND &lt;properties&gt;\r\n<\/pre>\n<p><span style=\"font-family: Celibri\"><span style=\"font-size: medium\"><span style=\"color: #121214\">The statement has two main properties that are replication and durable writes. The replication property includes class and replication factor. For the class property, the user has to enter the strategy name. <\/span><\/span><\/span><\/p>\n<p><span style=\"font-family: Celibri\"><span style=\"font-size: medium\"><span style=\"color: #121214\">For the replication factor, the user has to enter the number of replicas that have to be made. The durable_writes property includes the boolean values. These properties are optional. A user may or may not use these properties.<\/span><\/span><\/span><\/p>\n<p><strong><a href=\"https:\/\/data-flair.training\/blogs\/cassandra-cluster\/\">Have a look at Cassandra Cluster<\/a><\/strong><br \/>\n<span style=\"font-size: medium\"><strong><span style=\"font-family: Celibri\"><span style=\"color: #121214\">FULL SYNTAX:<\/span><\/span><\/strong><\/span><\/p>\n<pre class=\"EnlighterJSRAW\">CREATE KEYSPACE 'keyspace name'\r\nWITH replication{'class':'&lt;strategy name&gt;','replication factor':'&lt;number of replicas&gt;'}\r\nAND durable_writes='&lt;Boolean value&gt;';<\/pre>\n<p><span style=\"font-family: Celibri\"><span style=\"font-size: medium\"><span style=\"color: #121214\"><strong>Example:<\/strong> Let us create a keyspace named &#8216;keyspace 1&#8217; with simple strategy and 2 number of replicas. The durable writes for this keyspace is false.<\/span><\/span><\/span><\/p>\n<pre class=\"EnlighterJSRAW\">cqlsh&gt; CREATE KEYSPACE 'keyspace1'\r\n... WITH replication{'class':'simple strategy','replication factor':'2'}\r\n... AND durable_writes='false';<\/pre>\n<h3>b. Use<\/h3>\n<p><span style=\"font-family: Celibri\"><span style=\"font-size: medium\"><span style=\"color: #121214\">This command in Data Definition Command, is used to use a keyspace stored in a database. Cassandra uses keyword &#8216;USE&#8217; to perform the following function.<br \/>\n<strong>SYNTAX:<\/strong><\/span><\/span><\/span><\/p>\n<pre class=\"EnlighterJSRAW\">USE&lt;keyspace name&gt;\r\n<\/pre>\n<p><span style=\"font-family: Celibri\"><span style=\"font-size: medium\"><span style=\"color: #121214\"><strong>Example:<\/strong><br \/>\nLet us use the keyspace &#8216;keyspace1&#8217; that we made in the earlier example.<\/span><\/span><\/span><\/p>\n<p><strong><a href=\"https:\/\/data-flair.training\/blogs\/cassandra-api\/\">Let&#8217;s discuss Cassandra API<\/a><\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">cqlsh&gt;USE keyspace1;\r\ncqlsh; keyspace1&gt;<\/pre>\n<h3 class=\"western\">c. Alter Keyspace<\/h3>\n<p><span style=\"font-family: Celibri\"><span style=\"font-size: medium\"><span style=\"color: #121214\">This command is used to alter the properties of the keyspace. ALTER KEYSPACE command is used to do the operation. A user can alter replication and durable_writes properties.\u00a0Data definition command help\u00a0to\u00a0alter keyspace.\u00a0<\/span><\/span><\/span><br \/>\n<span style=\"font-family: Celibri\"><span style=\"font-size: medium\"><span style=\"color: #121214\"><strong>SYNTAX:<\/strong><\/span><\/span><\/span><\/p>\n<pre class=\"EnlighterJSRAW\">ALTER KEYSPACE &lt;keyspace name&gt; WITH &lt;properties&gt; AND &lt;properties&gt;<\/pre>\n<p><span style=\"font-family: Celibri\"><span style=\"font-size: medium\"><span style=\"color: #121214\">or<\/span><\/span><\/span><\/p>\n<pre class=\"EnlighterJSRAW\">ALTER KEYSPACE &lt;keyspace name&gt;\r\nWITH replication={'class':'strategy name','replication factor':'number of replicas'}\r\nAND durable_writes=&lt;'boolean type'&gt;;\\<\/pre>\n<p><span style=\"font-family: Celibri\"><span style=\"font-size: medium\"><span style=\"color: #121214\"><strong>Example:<\/strong> Let us alter the properties of keyspace1 from simple strategy to network topology strategy. The number of replicas, from 2 to 5 and boolean type, from false to true.<\/span><\/span><\/span><\/p>\n<pre class=\"EnlighterJSRAW\">cqlsh&gt; ALTER KEYSPACE keyspace1\r\n... WITH replication{'class':'NetworkTopologyStrategy','no. of replicas':'5'}\r\n... AND durable_writes= true;<\/pre>\n<p><strong><a href=\"https:\/\/data-flair.training\/blogs\/cassandra-curd-operation\/\">Let&#8217;s See Cassandra Curd Operation \u2013 Create, Update, Read &amp; Delete in Detail<\/a><\/strong><\/p>\n<h3>d. Drop Keyspace<\/h3>\n<p><span style=\"font-family: Celibri\"><span style=\"font-size: medium\"><span style=\"color: #121214\">This command lets the user drop a keyspace. In other words, the user deletes the keyspace using this. To perform this operation we use DROP KEYSPACE keyword.<br \/>\n<strong>SYNTAX:<\/strong><br \/>\n<\/span><\/span><\/span><\/p>\n<pre class=\"EnlighterJSRAW\">DROP KEYSPACE&lt;keyspace name&gt;;<\/pre>\n<p><span style=\"font-family: Celibri\"><span style=\"font-size: medium\"><span style=\"color: #121214\"><strong>Example:<\/strong> Let us delete the keyspace we developed in the previous example.<br \/>\n<\/span><\/span><\/span><\/p>\n<pre class=\"EnlighterJSRAW\">cqlsh&gt; DROP KEYSPACE keyspace1;<\/pre>\n<h3>e. Create Table<\/h3>\n<p><span style=\"font-family: Celibri\"><span style=\"font-size: medium\"><span style=\"color: #121214\">A table is one of the most important storage units in Cassandra Database. The user has the ability to create a table that can be deployed to the Cassandra database.<\/span><\/span><\/span><\/p>\n<p><strong><a href=\"https:\/\/data-flair.training\/blogs\/cassandra-troubleshooting\/\">Have a look at Cassandra Troubleshooting<\/a><\/strong><br \/>\n<span style=\"font-family: Celibri\"><span style=\"font-size: medium\"><span style=\"color: #121214\"><strong>SYNTAX:<\/strong><br \/>\n<\/span><\/span><\/span><\/p>\n<pre class=\"EnlighterJSRAW\">CREATE TABLE\/COLUMN FAMILY&lt;table name&gt;\r\n('&lt;column-definition&gt;','&lt;columan-definition&gt;')\r\n(WITH&lt;option&gt;AND&lt;option&gt;)<\/pre>\n<p><span style=\"font-family: Celibri\"><span style=\"font-size: medium\"><span style=\"color: #121214\">The statement allowed the user to set field name and their respective field type and also the primary. The primary key is basically a main column that is used for identification of a row.<\/span><\/span><\/span><br \/>\n<span style=\"font-size: medium\"><strong><span style=\"font-family: Celibri\"><span style=\"color: #121214\">FULL SYNTAX:<\/span><\/span><\/strong><\/span><\/p>\n<pre class=\"EnlighterJSRAW\">CREATE TABLE &lt;table name&gt;\r\n&lt;field name1&gt; &lt;field type1&gt;\r\n&lt;field name2&gt; &lt;field type2&gt;\r\n&lt;field name3&gt; &lt;field type3&gt;\r\nprimary key(&lt;field name&gt;);<\/pre>\n<p><span style=\"font-family: Celibri\"><span style=\"font-size: medium\"><span style=\"color: #121214\"><strong>EXAMPLE:<\/strong> Let us create a table &#8216;student &#8216; with fields, name, age, id, and branch. Primary key is id.<\/span><\/span><\/span><\/p>\n<pre class=\"EnlighterJSRAW\">cqlsh;keyspace1&gt; CREATE TABLE student\r\n... name text,\r\n... age int,\r\n... id int,\r\n... branch text,\r\n... primary key (id);<\/pre>\n<h3 class=\"western\">f. Alter Table<\/h3>\n<p><span style=\"color: #121214\"><span style=\"font-family: Celibri\"><span style=\"font-size: medium\">A User can change the properties of the table. We use ALTER TABLE command to perform the following operation. The user can perform two operations, add a column and drop a column.<\/span><\/span><\/span><br \/>\n<span style=\"font-family: Celibri\"><span style=\"font-size: medium\"><span style=\"color: #121214\"><strong>SYNTAX:<\/strong><br \/>\n<\/span><\/span><\/span><\/p>\n<pre class=\"EnlighterJSRAW\">ALTER TABLE\/COLUMN FAMILY &lt;table name&gt;&lt;instruction&gt;;<\/pre>\n<p><strong><a href=\"https:\/\/data-flair.training\/blogs\/cassandra-architecture\/\">Read About Architecture of\u00a0Cassandra in Detail<\/a><\/strong><\/p>\n<h4><span style=\"color: #4f81bd\"><span style=\"font-family: Cambria, serif\"><b><span style=\"font-family: Celibri\"><span style=\"font-size: medium\">i. Add a column<\/span><\/span><\/b><\/span><\/span><\/h4>\n<p><span style=\"color: #121214\"><span style=\"font-family: Celibri\"><span style=\"font-size: medium\">To add a column the user can use the following syntax.<br \/>\n<\/span><\/span><\/span><\/p>\n<pre class=\"EnlighterJSRAW\">ALTER TABLE &lt;table name&gt;\r\nADD &lt;new column&gt; &lt;data type&gt;;<\/pre>\n<h4><span style=\"color: #4f81bd\"><span style=\"font-family: Cambria, serif\"><b><span style=\"font-family: Celibri\"><span style=\"font-size: medium\">ii. Drop a column<\/span><\/span><\/b><\/span><\/span><\/h4>\n<p><span style=\"color: #121214\"><span style=\"font-family: Celibri\"><span style=\"font-size: medium\">to drop a column user can use the following syntax.<br \/>\n<\/span><\/span><\/span><\/p>\n<pre class=\"EnlighterJSRAW\">ALTER TABLE &lt;table name&gt;\r\nDROP &lt;column name&gt;;<\/pre>\n<p><span style=\"font-family: Celibri\"><span style=\"font-size: medium\"><span style=\"color: #121214\"><strong>Example:<\/strong> Let us alter the table student. In the table, we will add a column of a city and drop the column age.<\/span><\/span><\/span><br \/>\n<span style=\"font-family: Celibri\"><span style=\"font-size: medium\"><span style=\"color: #121214\">ALTER TABLE student<br \/>\n<\/span><\/span><\/span><\/p>\n<pre class=\"EnlighterJSRAW\">ADD city text;\r\nALTER TYPE student\r\nDROP age;<\/pre>\n<h3 class=\"western\">g. Truncate Table<\/h3>\n<p><span style=\"font-family: Celibri\"><span style=\"font-size: medium\"><span style=\"color: #121214\">If a table is not required by the user, the user can truncate the whole table. The keyword used to truncate the table is TRUNCATE. When the user truncates the table, all the entry in the rows is deleted. The table stays but with zero rows.<\/span><\/span><\/span><\/p>\n<p><strong><a href=\"https:\/\/data-flair.training\/blogs\/cassandra-user-defined-types\/\">Let&#8217;s revise Cassandra User-Defined Types<\/a><\/strong><br \/>\n<span style=\"font-family: Celibri\"><span style=\"font-size: medium\"><span style=\"color: #121214\"><strong>SYNTAX:<\/strong><br \/>\n<\/span><\/span><\/span><\/p>\n<pre class=\"EnlighterJSRAW\">TRUNCATE&lt;table name&gt;;<\/pre>\n<p><span style=\"font-family: Celibri\"><span style=\"font-size: medium\"><span style=\"color: #121214\"><strong>Example:<\/strong> Let&#8217;s truncate the table student.<br \/>\n<\/span><\/span><\/span><\/p>\n<pre class=\"EnlighterJSRAW\">TRUNCATE student;<\/pre>\n<p><strong><a href=\"https:\/\/data-flair.training\/blogs\/cassandra-data-model\/\">Do you know How Cassandra Stores Data &#8211;\u00a0Cassandra Data Model<\/a><\/strong><\/p>\n<h3 class=\"western\">h. Drop Table<\/h3>\n<p><span style=\"font-family: Celibri\"><span style=\"font-size: medium\"><span style=\"color: #121214\">If the user wants to completely delete the table from the database, the user can use this command. We use DROP TABLE keyword to perform the following operation.<\/span><\/span><\/span><br \/>\n<span style=\"font-family: Celibri\"><span style=\"font-size: medium\"><span style=\"color: #121214\"><strong>SYNTAX:<\/strong><br \/>\n<\/span><\/span><\/span><\/p>\n<pre class=\"EnlighterJSRAW\">DROP TABLE&lt;table name&gt;;<\/pre>\n<p><span style=\"font-family: Celibri\"><span style=\"font-size: medium\"><span style=\"color: #121214\"><strong>Example:<\/strong> In this example, we will delete the table student.<br \/>\n<\/span><\/span><\/span><\/p>\n<pre class=\"EnlighterJSRAW\">DROP TABLE student;<\/pre>\n<h3>i. Create Index<\/h3>\n<p><span style=\"font-family: Celibri\"><span style=\"font-size: medium\">The user can set an index on a field in a table. We use CREATE INDEX keyword to perform the following operation.<\/span><\/span><br \/>\n<span style=\"font-family: Celibri\"><span style=\"font-size: medium\"><strong>SYNTAX:<\/strong><br \/>\n<\/span><\/span><\/p>\n<pre class=\"EnlighterJSRAW\">CREATE INDEX &lt;field name&gt; ON &lt;table name&gt;<\/pre>\n<p><span style=\"font-family: Celibri\"><span style=\"font-size: medium\"><span style=\"color: #121214\"><strong>Example:<\/strong> In this example, we will create an index on &#8216;id&#8217; at table &#8216;student&#8217;.<br \/>\n<\/span><\/span><\/span><\/p>\n<p><strong><a href=\"https:\/\/data-flair.training\/blogs\/cassandra-data-types\/\">Have a look at Cassandra Built-in Collection<\/a><\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">cqlsh;keyspcae1&gt; CREATE INDEX id ON student;<\/pre>\n<h3>j. Drop Index<\/h3>\n<p><span style=\"font-family: Celibri\"><span style=\"font-size: medium\"><span style=\"color: #121214\">A user\u00a0can drop the set index on the field in a table. A user can use DROP INDEX keyword to perform the function.\u00a0Data Definition Command plays main role in it.\u00a0<\/span><\/span><\/span><br \/>\n<span style=\"font-family: Celibri\"><span style=\"font-size: medium\"><span style=\"color: #121214\"><strong>SYNTAX:<\/strong><br \/>\n<\/span><\/span><\/span><\/p>\n<pre class=\"EnlighterJSRAW\">DROP INDEX &lt;field name&gt;;<\/pre>\n<p><span style=\"font-family: Celibri\"><span style=\"font-size: medium\"><span style=\"color: #121214\"><strong>Example:<\/strong> In this example, we will drop the index on &#8216;id&#8217; at table &#8216;student&#8217;.<br \/>\n<\/span><\/span><\/span><\/p>\n<pre class=\"EnlighterJSRAW\">cqlsh;keyspcae1&gt; DROP INDEX id;<\/pre>\n<p><strong><a href=\"https:\/\/data-flair.training\/blogs\/cassandra-applications\/\">Let&#8217;s Explore\u00a0Applications of Cassandra in Detail<\/a><\/strong><br \/>\nSo, this was all about CQL-Data Definition Command Tutorial. Hope you like our explanation.<\/p>\n<h2 class=\"western\">4. Conclusion<\/h2>\n<p>Hence, in this CQL tutorial, we studied Data definition Command in Cassandra Query Langauge (CQL), Create keyspace, use, alter keyspace, drop\u00a0keyspace, create table, alter table, truncate table, drop table, create index, and drop index with examples and syntax.<\/p>\n<p>These data definition commands help to create &amp; alter Cassandra keyspace, table, and index.<\/p>\n<p>Furthermore, if you have any query regarding CQL Data definition Command, feel free to ask in the\u00a0command box.<br \/>\nRelated Topic- <strong><a href=\"https:\/\/data-flair.training\/blogs\/cassandra-interview-questions-and-answers\/\">Cassandra Interview Questions<\/a><\/strong><br \/>\n<strong><a href=\"https:\/\/en.wikipedia.org\/wiki\/Apache_Cassandra\">For reference<\/a><\/strong><span hidden class=\"__iawmlf-post-loop-links\" data-iawmlf-links=\"[{&quot;id&quot;:1921,&quot;href&quot;:&quot;https:\\\/\\\/en.wikipedia.org\\\/wiki\\\/Apache_Cassandra&quot;,&quot;archived_href&quot;:&quot;http:\\\/\\\/web-wp.archive.org\\\/web\\\/20251002025136\\\/https:\\\/\\\/en.wikipedia.org\\\/wiki\\\/Apache_Cassandra&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2025-12-10 09:49:52&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2025-12-13 15:07:28&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2025-12-17 07:34:35&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2025-12-20 10:47:40&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2025-12-24 08:09:26&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2025-12-30 01:58:56&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-05 11:47:53&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-12 05:15:45&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-15 19:58:10&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-19 02:58:29&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-26 23:53:09&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-30 03:59:41&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-02 06:12:23&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-05 10:14:45&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-08 10:44:18&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-15 03:58:34&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-20 14:25:59&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-25 07:05:25&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-02 10:59:48&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-06 04:44:04&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-09 15:01:14&quot;,&quot;http_code&quot;:429},{&quot;date&quot;:&quot;2026-03-13 14:45:16&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-17 05:15:46&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-21 14:03:56&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-25 10:23:04&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-28 10:38:31&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-01 04:38:40&quot;,&quot;http_code&quot;:429},{&quot;date&quot;:&quot;2026-04-08 20:21:21&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-12 19:15:18&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-17 17:24:15&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-22 10:00:10&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-28 14:52:57&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-05-03 10:48:23&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-05-07 07:58:47&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-05-11 14:45:10&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-05-16 06:52:18&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-05-21 08:00:07&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-05-25 00:20:49&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-05-29 18:14:03&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-06-05 16:45:03&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-06-12 22:35:40&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-06-18 05:15:56&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-06-22 16:20:52&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-06-26 00:04:56&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-06-29 14:51:54&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-07-02 17:35:54&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-07-06 20:45:34&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-07-10 10:43:27&quot;,&quot;http_code&quot;:200}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-07-10 10:43:27&quot;,&quot;http_code&quot;:200},&quot;process&quot;:&quot;done&quot;}]\"><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. Objective In our last tutorial, we studied\u00a010 Cassandra Shell Commands\u00a0and in this Cassandra Tutorial, we will deal with the Data Definition Command\u00a0in CQL. Moreover, we will discuss keyspace in Cassandra and its various&#46;&#46;&#46;<\/p>\n","protected":false},"author":7,"featured_media":16629,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[432,433,2362,3024,3070,3072,3089,3301,3303,4072,4073,4074,8027,14970,15189],"class_list":["post-16611","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cassandra","tag-alter-keyspace","tag-alter-table","tag-cassandra-keyspace","tag-cql-data-definition-command","tag-create-index","tag-create-keyspace","tag-create-table","tag-data-definition-command","tag-data-definition-command-in-cql","tag-drop-index","tag-drop-keyspace","tag-drop-table","tag-keyspace-in-cassandra","tag-truncate-table","tag-use"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Data Definition Command - Cassandra Query Language - DataFlair<\/title>\n<meta name=\"description\" content=\"Data Definition Command -Cassandra Query Language, CQL,Cassandra Keyspace: Keyspace-Create,Alter,Drop,Table-Create, Alter,Truncate,Drop,Index- Create &amp; Drop\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/data-definition-command-cql\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Data Definition Command - Cassandra Query Language - DataFlair\" \/>\n<meta property=\"og:description\" content=\"Data Definition Command -Cassandra Query Language, CQL,Cassandra Keyspace: Keyspace-Create,Alter,Drop,Table-Create, Alter,Truncate,Drop,Index- Create &amp; Drop\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/data-definition-command-cql\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2018-05-26T07:30:27+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-04-05T08:15:31+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/data-definition-command-01.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Data Definition Command - Cassandra Query Language - DataFlair","description":"Data Definition Command -Cassandra Query Language, CQL,Cassandra Keyspace: Keyspace-Create,Alter,Drop,Table-Create, Alter,Truncate,Drop,Index- Create & Drop","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/data-flair.training\/blogs\/data-definition-command-cql\/","og_locale":"en_US","og_type":"article","og_title":"Data Definition Command - Cassandra Query Language - DataFlair","og_description":"Data Definition Command -Cassandra Query Language, CQL,Cassandra Keyspace: Keyspace-Create,Alter,Drop,Table-Create, Alter,Truncate,Drop,Index- Create & Drop","og_url":"https:\/\/data-flair.training\/blogs\/data-definition-command-cql\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2018-05-26T07:30:27+00:00","article_modified_time":"2021-04-05T08:15:31+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/data-definition-command-01.jpg","type":"image\/jpeg"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/data-definition-command-cql\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/data-definition-command-cql\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/beb0cab24b7aa54423a3b50e669a9dcd"},"headline":"Data Definition Command &#8211; Cassandra Query Language","datePublished":"2018-05-26T07:30:27+00:00","dateModified":"2021-04-05T08:15:31+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/data-definition-command-cql\/"},"wordCount":1037,"commentCount":1,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/data-definition-command-cql\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/data-definition-command-01.jpg","keywords":["Alter Keyspace","Alter Table","Cassandra keyspace","CQL Data Definition Command","Create Index","Create Keyspace","Create Table","Data Definition Command","Data Definition Command in CQL","Drop Index","Drop Keyspace","Drop Table","Keyspace in Cassandra","Truncate Table","Use"],"articleSection":["Cassandra Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/data-definition-command-cql\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/data-definition-command-cql\/","url":"https:\/\/data-flair.training\/blogs\/data-definition-command-cql\/","name":"Data Definition Command - Cassandra Query Language - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/data-definition-command-cql\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/data-definition-command-cql\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/data-definition-command-01.jpg","datePublished":"2018-05-26T07:30:27+00:00","dateModified":"2021-04-05T08:15:31+00:00","description":"Data Definition Command -Cassandra Query Language, CQL,Cassandra Keyspace: Keyspace-Create,Alter,Drop,Table-Create, Alter,Truncate,Drop,Index- Create & Drop","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/data-definition-command-cql\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/data-definition-command-cql\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/data-definition-command-cql\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/data-definition-command-01.jpg","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/data-definition-command-01.jpg","width":1200,"height":628,"caption":"Data Definition Command - Cassandra Query Language"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/data-definition-command-cql\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"Cassandra Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/cassandra\/"},{"@type":"ListItem","position":3,"name":"Data Definition Command &#8211; Cassandra Query Language"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/beb0cab24b7aa54423a3b50e669a9dcd","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/c322416204232f4dd97ef3901b0a499a5d34d7ba7fe333f4bfe53a907873d293?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/c322416204232f4dd97ef3901b0a499a5d34d7ba7fe333f4bfe53a907873d293?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c322416204232f4dd97ef3901b0a499a5d34d7ba7fe333f4bfe53a907873d293?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"DataFlair Team specializes in creating clear, actionable content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Backed by industry expertise, we make learning easy and career-oriented for beginners and pros alike.","url":"https:\/\/data-flair.training\/blogs\/author\/dfteam3\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/16611","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=16611"}],"version-history":[{"count":6,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/16611\/revisions"}],"predecessor-version":[{"id":90513,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/16611\/revisions\/90513"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/16629"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=16611"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=16611"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=16611"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}