5
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Cassandraでcqlツール(gui)を使ってみる

Last updated at Posted at 2015-08-12

Cassandraでcqlツール(gui)を使ってみる

インストール

http://www.datastax.com/what-we-offer/products-services/devcenter
からDataStax DevCenterをインストール

DevCenter.exeから起動して
ConnectionsビューからCreate a new connection(ケーブルと+のアイコン)を行う

接続

今回はローカルのCassandraを使用するので
Connerction name に「localhost」
Native Protco; portに「9042」
を入れる
(Cassandraのバージョンが古いとつながらない可能性あり)

使い方

http://docs.datastax.com/en/cql/3.0/cql/cql_reference/cqlCommandsTOC.html
使い方

SQL的な感じでCassandraを使うことができる

keyspaceの作成

create keyspace testkeyspace with replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };

with replicationの部分はレプリケーションに関することらしい。
複数のマシン(分散システム)でどのように、どのくらいデータを保存するかの設定らしい。
今はただの遊びなので無視。

ColumnFamilyの作成

in keyspaceを作成したkeyspaceに変更して
create table user( corp text PRIMARY KEY, department text, name text );

データの挿入

insert into user (corp,department,name) values ('yamada-Shoji','Accounting','takeda'); insert into user (corp,department,name) values ('yamada-Shoji','Accounting','takahashi'); insert into user (corp,department,name) values ('yamada-Shoji','Finance','tanaka'); insert into user (corp,department,name) values ('yamaguchi-Shoji','Accounting','tutumi');

select * from user;

PRIMARY KEYが重複した場合(yamada-Shojiの部分)は上書きされてしまっている

deleteやupdateも同様にできそう

5
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?