{"id":20276,"date":"2013-05-10T12:52:27","date_gmt":"2013-05-10T07:22:27","guid":{"rendered":"http:\/\/vskills.in\/certification\/tutorial\/?p=20276"},"modified":"2024-04-12T14:16:38","modified_gmt":"2024-04-12T08:46:38","slug":"client-cli-and-commands","status":"publish","type":"page","link":"https:\/\/www.vskills.in\/certification\/tutorial\/client-cli-and-commands\/","title":{"rendered":"Client CLI and commands"},"content":{"rendered":"<p><a class=\"vsc\" href=\"http:\/\/www.vskills.in\/certification\/Certified-Cassandra-Professional\"><span class=\"vsc-cn\" style=\"text-align: center;\"><span style=\"color: red;\">Certify and Increase Opportunity.<\/span><br \/>\n<span style=\"color: green;\">Be <\/span><br \/>\nGovt. Certified Apache Cassandra Professional<br \/>\n<\/span><\/a><\/p>\n<p>Client CLI and commands<\/p>\n<p><span style=\"text-decoration: underline;\"><strong>Cassandra CLI<\/strong><\/span><\/p>\n<p>Cassandra ships with a very basic interactive command line interface. Using the CLI you can connect to remote nodes in the cluster to create or update your schema and set and retrieve records.<\/p>\n<h2 id=\"Starting_the_CLI\">Starting the CLI<\/h2>\n<p>You can start the CLI using the <tt>bin\/cassandra-cli<\/tt> script in your Cassandra installation (<tt>bin\\cassandra-cli.bat<\/tt> on windows). If you are evaluating a local cassandra node then be sure that it has been correctly configured and successfully started before starting the CLI.<\/p>\n<p>If successful you will see output similar to this:<\/p>\n<pre>Welcome to cassandra CLI.\n\nType 'help;' or '?' for help. Type 'quit;' or 'exit;' to quit.<\/pre>\n<p>You must then specify a system to connect to:<\/p>\n<pre>connect localhost\/9160;<\/pre>\n<h2 id=\"Creating_a_Keyspace\">Creating a Keyspace<\/h2>\n<p>We first create a keyspace to run our examples in.<\/p>\n<pre>create keyspace Twissandra;<\/pre>\n<h2 id=\"Selecting_the_keyspace_to_user\">Selecting the keyspace to user<\/h2>\n<p>We must then select our example keyspace as our new context before we can run any queries.<\/p>\n<pre>use Twissandra;<\/pre>\n<h2 id=\"To_Create_A_Column\">To Create A Column<\/h2>\n<p>We can then create a column to play with.<\/p>\n<pre>create column family User with comparator = UTF8Type;<\/pre>\n<p>For the later examples to work you must also update the schema using the following command. This will set the return type for the first and last name to make them human readable. It will also add and index for the age field so that you filter your gets using the Users name field.<\/p>\n<pre>update column family User with\n        column_metadata =\n        [\n        {column_name: first, validation_class: UTF8Type},\n        {column_name: last, validation_class: UTF8Type},\n        {column_name: age, validation_class: UTF8Type, index_type: KEYS}\n        ];<\/pre>\n<h2 id=\"To_Add_Data\">To Add Data<\/h2>\n<p>To add data we want to into our new column we must first specify our default key type otherwise we would have to specify it for each key using the format <tt>[utf8('keyname')]<\/tt> this is probably advisable if you have mixed key types but makes simple cases harder to read.<\/p>\n<p>So we run the command below, which will last the length of you cli session. On quitting and restarting we must run it again.<\/p>\n<pre>assume User keys as utf8;<\/pre>\n<p>and then we add our data.<\/p>\n<pre>set User['jsmith']['first'] = 'John';\nset User['jsmith']['last'] = 'Smith';\nset User['jsmith']['age'] = '38';<\/pre>\n<p>If you get the error like this <tt>cannot&nbsp;parse&nbsp;'John'&nbsp;as&nbsp;hex&nbsp;bytes<\/tt>, then it likely you either haven&#8217;t set your default key type or you haven&#8217;t updated your schema as in the create column example.<\/p>\n<h2 id=\"To_Update_Data\">To Update Data<\/h2>\n<p>If we need to update a value we simply set it again.<\/p>\n<pre>set User['jsmith']['first'] = 'Jack';<\/pre>\n<h2 id=\"To_Get_Data\">To Get Data<\/h2>\n<p>Now let&#8217;s read back the <tt>jsmith<\/tt> row to see what it contains:<\/p>\n<pre>get User['jsmith'];<\/pre>\n<h2 id=\"To_Query_Data\">To Query Data<\/h2>\n<pre>get User where age = '12';<\/pre>\n<h2 id=\"For__help\">For help<\/h2>\n<pre>help;<\/pre>\n<h2 id=\"To_Quit\">To Quit<\/h2>\n<pre>quit;<\/pre>\n<h2 id=\"To_Execute_Script\">To Execute Script<\/h2>\n<pre>bin\/cassandra-cli -host localhost -port 9160 -f script.txt<\/pre>\n<div class=\"apply\">\n<h3>Apply for Apache Cassandra Certification Now!!<\/h3>\n<p><a href=\"http:\/\/www.vskills.in\/certification\/Certified-Cassandra-Professional\">http:\/\/www.vskills.in\/certification\/Certified-Apache-Cassandra-Professional<\/a><\/p>\n<h4>Go to Tutorial- <a href=\"https:\/\/www.vskills.in\/certification\/tutorial\/apache-cassandra-professional\/\" target=\"_blank\" rel=\"noopener noreferrer\"><strong>Certified Apache Cassandra Professional Tutorial<\/strong><\/a><\/h4>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Certify and Increase Opportunity. Be Govt. Certified Apache Cassandra Professional Client CLI and commands Cassandra CLI Cassandra ships with a very basic interactive command line interface. Using the CLI you can connect to remote nodes in the cluster to create or update your schema and set and retrieve records. Starting the CLI You can start&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"categories":[63],"tags":[],"class_list":["post-20276","page","type-page","status-publish","hentry","category-apache-cassandra"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Client CLI and commands - Tutorial<\/title>\n<meta name=\"description\" content=\"Client CLI and commands Vskills Government Certification in Apache Cassandra is very popular in India amongst developers working in the IT Bid data industry.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.vskills.in\/certification\/tutorial\/client-cli-and-commands\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Client CLI and commands - Tutorial\" \/>\n<meta property=\"og:description\" content=\"Client CLI and commands Vskills Government Certification in Apache Cassandra is very popular in India amongst developers working in the IT Bid data industry.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.vskills.in\/certification\/tutorial\/client-cli-and-commands\/\" \/>\n<meta property=\"og:site_name\" content=\"Tutorial\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/vskills.in\/\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-12T08:46:38+00:00\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/client-cli-and-commands\/\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/client-cli-and-commands\/\",\"name\":\"Client CLI and commands - Tutorial\",\"isPartOf\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#website\"},\"datePublished\":\"2013-05-10T07:22:27+00:00\",\"dateModified\":\"2024-04-12T08:46:38+00:00\",\"description\":\"Client CLI and commands Vskills Government Certification in Apache Cassandra is very popular in India amongst developers working in the IT Bid data industry.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/client-cli-and-commands\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.vskills.in\/certification\/tutorial\/client-cli-and-commands\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/client-cli-and-commands\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Client CLI and commands\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#website\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\",\"name\":\"Tutorial\",\"description\":\"Vskills - A initiative in elearning and certification\",\"publisher\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.vskills.in\/certification\/tutorial\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#organization\",\"name\":\"Vskills\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg\",\"contentUrl\":\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg\",\"width\":73,\"height\":55,\"caption\":\"Vskills\"},\"image\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/vskills.in\/\",\"https:\/\/x.com\/vskills_in\",\"https:\/\/www.linkedin.com\/company-beta\/1371554\/\",\"https:\/\/www.youtube.com\/channel\/UCMWnscxPwRF_PqXo9B7q_Tw\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Client CLI and commands - Tutorial","description":"Client CLI and commands Vskills Government Certification in Apache Cassandra is very popular in India amongst developers working in the IT Bid data industry.","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:\/\/www.vskills.in\/certification\/tutorial\/client-cli-and-commands\/","og_locale":"en_US","og_type":"article","og_title":"Client CLI and commands - Tutorial","og_description":"Client CLI and commands Vskills Government Certification in Apache Cassandra is very popular in India amongst developers working in the IT Bid data industry.","og_url":"https:\/\/www.vskills.in\/certification\/tutorial\/client-cli-and-commands\/","og_site_name":"Tutorial","article_publisher":"https:\/\/www.facebook.com\/vskills.in\/","article_modified_time":"2024-04-12T08:46:38+00:00","twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/client-cli-and-commands\/","url":"https:\/\/www.vskills.in\/certification\/tutorial\/client-cli-and-commands\/","name":"Client CLI and commands - Tutorial","isPartOf":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#website"},"datePublished":"2013-05-10T07:22:27+00:00","dateModified":"2024-04-12T08:46:38+00:00","description":"Client CLI and commands Vskills Government Certification in Apache Cassandra is very popular in India amongst developers working in the IT Bid data industry.","breadcrumb":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/client-cli-and-commands\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.vskills.in\/certification\/tutorial\/client-cli-and-commands\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/client-cli-and-commands\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.vskills.in\/certification\/tutorial\/"},{"@type":"ListItem","position":2,"name":"Client CLI and commands"}]},{"@type":"WebSite","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#website","url":"https:\/\/www.vskills.in\/certification\/tutorial\/","name":"Tutorial","description":"Vskills - A initiative in elearning and certification","publisher":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.vskills.in\/certification\/tutorial\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#organization","name":"Vskills","url":"https:\/\/www.vskills.in\/certification\/tutorial\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/","url":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg","contentUrl":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg","width":73,"height":55,"caption":"Vskills"},"image":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/vskills.in\/","https:\/\/x.com\/vskills_in","https:\/\/www.linkedin.com\/company-beta\/1371554\/","https:\/\/www.youtube.com\/channel\/UCMWnscxPwRF_PqXo9B7q_Tw"]}]}},"_links":{"self":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/20276","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/comments?post=20276"}],"version-history":[{"count":11,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/20276\/revisions"}],"predecessor-version":[{"id":122152,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/20276\/revisions\/122152"}],"wp:attachment":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/media?parent=20276"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/categories?post=20276"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/tags?post=20276"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}