Prepare for the Cassandra certification. Use flashcards, multiple-choice questions with explanations to help you master the subject. Gear up for your Cassandra exam!

Each practice test/flash card set has 50 randomly selected questions from a bank of over 500. You'll get a new set of questions each time!

Practice this question and more.


Which of the following is a key restriction when altering a table in Cassandra?

  1. The primary key cannot be changed

  2. You cannot drop columns

  3. Only datatypes can be changed

  4. You must recreate the table to make any change

The correct answer is: The primary key cannot be changed

In Cassandra, a fundamental restriction when altering a table is that the primary key cannot be changed once it has been defined. The primary key in Cassandra serves as a unique identifier for the rows in a table and is crucial for the distribution of data across nodes. Changing the primary key would not only redefine the unique structure of the table but would also affect data distribution, replication, and potential access patterns. Therefore, maintaining the integrity of the primary key throughout a table's lifecycle is paramount, which is why this statement holds true. The other options highlight misconceptions about table alterations in Cassandra. For instance, columns can be dropped, provided they are not part of the primary key. While datatypes of columns can typically be altered, this is limited to some specific changes and does not encompass all scenarios. Lastly, although recreating a table is sometimes necessary for significant structural changes, it is not a blanket requirement for every modification made to a Cassandra table, especially when it comes to adding or altering non-primary key columns. Thus, the insistence on the immutability of the primary key during alterations underscores the correct answer.