zoukankan      html  css  js  c++  java
  • cassandra基本操作

    basic operate
    1. 创建keyspace
    基本语句:CREATE KEYSPACE <identifier> WITH <properties>
    案例:
    CREATE KEYSPACE tutorialspoint
    WITH replication = {'class':'SimpleStrategy', 'replication_factor' : 3};


    2. 修改keyspace:
    ALTER KEYSPACE tutorialspoint
    WITH replication = {'class':'NetworkTopologyStrategy', 'replication_factor' : 3};


    3. 删除keyspace
    DROP KEYSPACE tutorialspoint;


    4. 创建Table
    CREATE TABLE tablename(
    column1 name datatype PRIMARYKEY,
    column2 name data type,
    column3 name data type.
    )
    或者
    CREATE TABLE tablename(
    column1 name data type,
    column2 name data type,
    column3 name data type,
    PRIMARY KEY (column1)
    )


    5. 修改Table
    使用ALTER命令,可以执行以下操作:
    添加列:ALTER TABLE table name ADD new column datatype;
    删除列:ALTER table name DROP column name;
    删除表:DROP TABLE <tablename>
    删除表内容:TRUNCATE <tablename>
    创建索引: CREATE INDEX name ON emp1 (emp_name);
    删除索引:drop index name;
    批处理
    使用BATCH,您可以同时执行多个修改语句(插入,更新,删除,类似于MySQL的事务提交)
    BEGIN BATCH
    ... INSERT INTO emp (emp_id, emp_city, emp_name, emp_phone, emp_sal) values( 4,'Pune','rajeev',9848022331, 30000);
    ... UPDATE emp SET emp_sal = 50000 WHERE emp_id =3;
    ... DELETE emp_city FROM emp WHERE emp_id = 2;
    ... APPLY BATCH;

    INSERT数据:INSERT INTO emp (emp_id, emp_name, emp_city,emp_phone, emp_sal) VALUES(1,'ram', 'Hyderabad', 9848022338, 50000);
    UPDATE数据:UPDATE emp SET emp_city='Delhi',emp_sal=50000 WHERE emp_id=2;
    SELECT数据:SELECT FROM <table name> WHERE <condition>;注意where后面的数据需要有索引
    DELETE数据:与SQL不同,CQL可以删除某个元素
    删除元素:DELETE emp_sal FROM emp WHERE emp_id=3;
    删除一行:DELETE FROM emp WHERE emp_id=3;

    记录一些总结较好的网址:

    基本数据结构:https://teddyma.gitbooks.io/learncassandra_cn/content/model/internal_data_structure.html
    Cassandra概念解释:http://www.cnblogs.com/loveis715/p/5299495.html
    Cassandra cql官方文档:https://docs.datastax.com/en/cql/3.3/cql/cqlIntro.html
    赵工的博客:http://zhaoyanblog.com/archives/920.html
    NodeTool文档:https://wiki.apache.org/cassandra/NodeTool
    Cassandra主要机制:https://docs.datastax.com/en/cassandra/3.0/cassandra/operations/opsRepairNodesTOC.html

  • 相关阅读:
    插入排序-Java
    选择排序-java
    逻辑回归----梯度上升
    logistic回归----- 随机梯度下降法
    JAVA实现聚类指标的计算Purity、NMI、RI、Precision、Recall、F值。
    Python 条形图绘制
    java中接口的注意事项
    算法-双向队列
    算法-manacher-最长回文子串-1
    算法-kmp-1
  • 原文地址:https://www.cnblogs.com/AndersonX/p/7144272.html
Copyright © 2011-2022 走看看