Reputation: 3179
When I am trying to create table like below
create table if not exists counter_temp(id counter PRIMARY KEY , comment text);
It is giving error as below
Multiple markers at this line
For a table with counter columns, all columns except the primary key must be type counter
counter type is not supported for PRIMARY KEY part
Question 1 :
What is the reason , counter column not allowed as part of primary key?
Question 2 : While I am trying to create as below
create table if not exists counter_temp(id uuid PRIMARY KEY, counter_t counter, comment text)
Error : Cant mix counter and non-counter columns in the same table
What is wrong here ? how to handle it correct way ?
Question 3 :
I have a table emp( emp_id counter, emp_name text) in Dev env where has data , now I need to copy that data into another SIT env emp( emp_id counter, emp_name text) table ?
Can it be done will it copy counter fields properly ?
Upvotes: 0
Views: 293
Reputation: 87119
Short answer for question 1 is No, as it was communicated in the error message. But Even if it was allowed, then it didn't make any sense - when you change value of the primary key, you're basically create a new row with different primary key.
for Q2 - if there is at least one counter
column in the table, then all other regular columns should have type counter
. If you need to add a comment field, just create a 2nd table, with UUID
primary key & insert or read data to/from 2 tables at the same time.
for Q3 - cqlsh's COPY
command supports tables with counters for newer Cassandra versions (where fix for CASSANDRA-9043 is implemented). Also, Spark Cassandra Connector is able to read from tables with counters & write to them. But in both cases make sure that the target table is empty, otherwise new values will be appended to existing ones.
Upvotes: 2