user43995
user43995

Reputation: 597

Cassandra : missing EOF at ')' when trying to create simple table

I am trying to create a simple table on Cassandra using cqlsh. The syntax is:


    CREATE TABLE TEST(
        timestamp timestamp,
        system_id text,
        hostname text,
        cpu_pct float,
        memory_used bigint,
        PRIMARY_KEY(system_id, timestamp)
    );

When I run this I get this error however. How to fix?


    ErrorMessage code=2000 [Syntax error in CQL query] message="line 8:0 missing EOF at ')' (...,PRIMARY_KEY(system_id, timestamp)[)];)"

Upvotes: 3

Views: 13081

Answers (3)

Riad
Riad

Reputation: 3860

CREATE TABLE TEST(
        timestamp timestamp,
        system_id text,
        hostname text,
        cpu_pct float,
        memory_used bigint,
        PRIMARY KEY(system_id, timestamp)
    );

See CQL CREATE TABLE Doc

Upvotes: 6

RussS
RussS

Reputation: 16576

PRIMARY_KEY() should be PRIMARY KEY().

Upvotes: 3

Jim Meyer
Jim Meyer

Reputation: 9475

You accidentally put an underscore between "PRIMARY KEY" instead of a space.

Also you might not want a field called "timestamp" since that is also a Cassandra type, so maybe call that "ts" or something.

Upvotes: 6

Related Questions