Alter Table in Cassandra

Cassandra Alter Table To alter an existing table, the ALTER TABLE command is used. This command can be used to add a column or to Drop a column. Syntax: ALTER (TABLE | COLUMN_FAMILY) tablename instruction To Add a Column: The column name should not conflict with the existing column names. The table should not be … Read more

Truncate Table in Cassandra

Cassandra Truncate Table To truncate a table in Cassandra, the TRUNCATE command is used. Thus, all the rows are deleted permanently from the table, but the table structure exists. Syntax: TRUNCATE table_name Example: Employees table: id name salary 1 Adi 50000 2 Bruno 30000 3 Chris 60000 4 Davis 20000 5 Eliza 15000id name salary … Read more

DROP Table in Cassandra

Cassandra DROP Table To drop a table in Cassandra, the DROP TABLE command is used. Syntax: DROP TABLE table_name Example: DROP TABLE employees;DROP TABLE employees; Explanation: In the above example, the table named “employees” is dropped. Use the “DESCRIBE” command for the verification of the table deletion. DESCRIBE COLUMNFAMILIES;

Create Table in Cassandra

Cassandra Create Table To create a table, the CREATE TABLE command is used in Cassandra. In Cassandra, a column family works just like a table in RDBMS, thus a column family is created in Cassandra, instead of a table. Syntax 1: CREATE (TABLE | COLUMNFAMILY) (” , ”) (WITH AND ) Syntax 2: Declaring a … Read more

Drop Keyspace in Cassandra

Cassandra Drop Keyspace We can drop keyspaces in Cassandra with all the data, column families, user-defined types and indexes, using the “DROP Keyspace” command. Before dropping the keyspace, a snapshot of the keyspace is taken if the keyspace exists; otherwise, an error will be returned. Syntax: DROP keyspace Keyspace_Name; Example: DROP keyspace durable_example;DROP keyspace durable_example; … Read more

Create Keyspace in Cassandra

Cassandra Create Keyspace To communicate with Cassandra the Cassandra Query Language (CQL) is used. A keyspace is an object working similar to an RDBMS database. It holds column families, the strategy used in the keyspace, indexes, user-defined types, replication factor, data centre awareness, etc. Syntax 1: To create keyspace: CREATE KEYSPACE <identifier> WITH <properties> Syntax … Read more

Alter Keyspace in Cassandra

Cassandra Alter Keyspace In a created keyspace, we can alter the replication factor, strategy name and the durable_writes properties using the “ALTER keyspace” command in Cassandra. Syntax 1: ALTER KEYSPACE WITH Syntax 2: ALTER KEYSPACE “KeySpace_Name” WITH replication = {‘class’: ‘Strategy name’, ‘replication_factor’: ‘No. Of replicas’}; Syntax 3: ALTER KEYSPACE Keyspace_Name with replication={‘class’:’Strategy_Name’, ‘replication_factor’: no … Read more

Cassandra CQLsh

Cassandra CQL shell or CQLsh is used to specify the way to use the Cassandra commands. Cassandra, when installed, provides a CQL shell prompt, to facilitate the users to communicate with it by executing the Cassandra commands on CQLsh.   CQLsh Options: Options Uses help To show help topics about the options of CQLsh commands. … Read more

Cassandra Data Model

The data model in Cassandra is different from RDBMS in many ways. A Cassandra Data Model contains the following elements: Cluster: A Cluster in Cassandra is the outermost container of the database. It contains one or more data centres. A data centre again acts as a collection of related nodes. With four nodes in a … Read more

Install Cassandra

Cassandra Installation Before installing Apache Cassandra, some prerequisites are required: The DataStax community edition. JDK installed. Window platform.   To Download and Install Cassandra: Open the DataStax community edition setup. Run the setup. Click on the Next button. Click again on the Next button. Confirm the location of the installation and then click on the … Read more