简体   繁体   中英

com.datastax.driver.core.exceptions.InvalidQueryException: PRIMARY KEY part sequence found in SET part

I am trying to update the table, then i am getting this exception:

com.datastax.driver.core.exceptions.InvalidQueryException: PRIMARY KEY part sequence found in SET part.

My table structure is

CREATE TABLE IF NOT EXISTS STYLINGBEE.LKPSTYLES(
    STYLEID ASCII,
    NAME ASCII,
    IMAGE ASCII,
    SEQUENCE INT,
    ACTIVE BOOLEAN,
    PRIMARY KEY (STYLEID,SEQUENCE)
)WITH CLUSTERING ORDER BY (SEQUENCE DESC);

While having your complete query would help, I can tell from the error message that you are trying to UPDATE a row's PRIMARY KEY . From the DataStax documentation on the UPDATE command :

The UPDATE SET operation is not valid on a primary key field.

This is why you are getting this particular error message. If you have inserted a row containing a part of the primary key that you need to update, you will have to remove that row and re-insert it.

Cassandra don't allow you to update primary key. You can not do something like below because SEQUENCE is part of primary key.

UPDATE STYLINGBEE.LKPSTYLES SET SEQUENCE = 1 WHERE STYLEID = 1000;

It looks like you are trying to update some row without STYLEID specified in your query (WHERE part). Could you please publish your CQL statement. I think this one link could help you: Why doesn't my Cassandra update work?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM