전체 페이지뷰

2018년 2월 7일 수요일

cassandra study

1. ordering
The actual ordering is determined by the token of the primary key—the way the token is calculated is opaque to us, but Cassandra lets us use the token() function to retrieve the token for a given value:

SELECT "username", token("username") FROM "users";

2. paging
we can paginate over arbitrarily large tables using multiple queries

SELECT * FROM "users"
WHERE token("username") > token('dave')
LIMIT 2;

3. update(Insert)
Suppose you try to insert data into a table with a primary key, which already exists; the data doesn't get updated in place. Rather, a new copy of the data is written, and the old copy is kept until it is deleted by some internal Cassandra mechanism. To demonstrate how this works, let's update one of the records using the INSERT statement.
Let's change Alice's email by running the following INSERT statement:

INSERT INTO "users" ("username", "email") VALUES ('alice', 'alice@yahoo.com');

DELETE FROM "users" WHERE "username" = 'alice';

UPDATE "users" SET "email" = 'alice@gmail.com',
"encrypted_password" = 0x8914977ed729792e403da53024c6069a9158b8c4
WHERE "username" = 'alice';

This tells us that the UPDATE statement has the same effect as an INSERT statement.




댓글 없음:

댓글 쓰기