> bin/cassandra-cli
Create a keyspace called "testing" (In MySQL, it's like a database).
> create keyspace testing;
Showing the keyspace (You will see the following):
> show keyspaces;
Keyspace: testing:
Replication Strategy: org.apache.cassandra.locator.NetworkTopologyStrategy
Durable Writes: true
Options: [datacenter1:1]
Column Families:
> use testing;
> create column family Users with comparator = 'UTF8Type';
> assume Users keys as utf8;
> update column family Users with column_metadata =
[
{column_name: first, validation_class: UTF8Type},
{column_name: last, validation_class: UTF8Type},
{column_name: age, validation_class: UTF8Type, index_type: KEYS}
];
Insert a user:
> set Users['jsmith']['first'] = 'John';
> set Users['jsmith']['last'] = 'Smith';
> set Users['jsmith']['age'] = '18';
> get Users[1]
=> (column=name, value=John, timestamp=1356649133517000)
=> (column=password, value=Smith, timestamp=1356649170278000)
Returned 2 results.
Elapsed time: 2.22 msec(s).
Update a user:
>set Users['jsmith']['first'] = 'Adam';
>get User where age = '18';
No comments:
Post a Comment