I'm a beginner in Cassandra and noSQL data base. For my exam i have to correct some instruction that the professor gave me. I have corrected some of these, but now i'm not able to fix this:
cqlsh> create COLUMNFAMILY post
... with comparator = UTF8Type
... and read_repair_chance = 0.1
... and keys_cached = 100
... and gc_grace = 0
... and min_compaction_threshold = 5
... and max_compaction_threshold = 31
I receive this error from CLI:
SyntaxException: line 2:0 mismatched input 'with' expecting '(' (create COLUMNFAMILY post[with] comparator...)
I would be really grateful if somebody can help me.
I hope it is understandable because my English isn't very good
Your columnfamily definition, or table definition (which is the more recent term for Cassandra tables) is missing the actual columns and a primary key, and it seems you have mixed your column definition (comparator = UTF8Type) with your table options, such as read_repair_chance and gc_grace_period.
All Cassandra tables must have at least one primary key column.
To create a minimal table post
in the keyspace ks
with default table options, you can do this:
CREATE TABLE ks.post (comparator text PRIMARY KEY);
To inspect the table definition and the full syntax for setting the table options:
describe table ks.post;
CREATE TABLE ks.post (
comparator text PRIMARY KEY
) WITH bloom_filter_fp_chance = 0.01
AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'}
AND comment = ''
AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'}
AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'}
AND crc_check_chance = 1.0
AND default_time_to_live = 0
AND gc_grace_seconds = 864000
AND max_index_interval = 2048
AND memtable_flush_period_in_ms = 0
AND min_index_interval = 128
AND speculative_retry = '99PERCENTILE';
Note: if you are using default table options, you do not have to specify them in your table creation command.
For documentation about table creation, check here for example: https://docs.datastax.com/en/dse/5.1/cql/cql/cql_reference/cql_commands/cqlCreateTable.html
or here: http://cassandra.apache.org/doc/latest/cql/ddl.html#create-table