Run the CQL language in the window environment first install the Python environment, not required under Linux, Cassandra built-in Python.
1. View python version: Python--version
2. Run Pythod:python./cqlsh
A. CQL definition statement:
Keyspace:
3. See the Help for creating a keyspace: helping create keyspace;
4. Create Keyspace:create keyspace ks1 with replication = {' class ': ' Simplestrategy ', ' Replication_factor ': 1};
5. View the structure of the keyspace: Desc keyspace ks1;
6. Modify Keyspace:alter keyspace ks1 with replication = {' class ': ' Simplestrategy ', ' Replication_factor ': 2};
7. Delete Keyspace:drop keyspace KS1
8. Switch to Keyspace:use KS1
Column families:
9. Create a column family:
CREATE TABLE TestTable (
Name text,
Age int,
Profile text,
PRIMARY KEY (name)
);
10. View the column families created: Desc table testtable
11. Modify the comment content of the column family: ALTER TABLE testtable with comment = ' test ';
12. Add a column to the column family: ALTER TABLE testtable add sex text;
13. Remove a column from the column family: ALTER TABLE testtable drop sex;
14. Delete Column family: drop table testtable;
15. Clear the Column family data: truncate testtable;
Index:
16. Create a second index (the index system automatically named): Create index on student (name);
17. Delete indexes: Drop index STUDENT_NAME_IDX;
Custom data types:
18. Creating a custom Data type: Create Type address (country text, province text, city text, road);
Other operations are similar to those for column families.
Trigger:
19. Create a trigger:
Two. The CQL data manipulation statement (90% and the relational database is the same, but the statistic function in CQL can only use count, and the property that appears after the WHERE keyword can only
Is primary key, the composite primary key can only be the first attribute to appear, if it is to be added to allow filtering, non-primary key properties must create a second index
To appear in the back of the Where)
1.insert inserting data: INSERT into student (Orderid,age,name,sex) VALUES (10001,20, ' Zhangsan ', ' Mans ');
2.select Query statement: SELECT * from student;
3.update UPDATE statement: Update student set name= ' Lisi ' where orderid=10001;
4.delete Delete the data for the Age column: Delete age from student where orderid=10001;
5.delete Delete the entire row of data: Delete from student where orderid=10001;
Basic use of Cassandra Query Language CQL