- Learning Apache Cassandra(Second Edition)
- Sandeep Yarabarla
- 252字
- 2021-07-03 00:19:27
Creating a keyspace
A keyspace is a collection of related tables equivalent to a database in a relational system. To create keyspace, issue the following statement in the CQL shell:
cqlsh> CREATE KEYSPACE "users"
WITH REPLICATION = {
'class': 'SimpleStrategy', 'replication_factor': 1
};
Here, we created a keyspace called users. When we create a keyspace, we have to specify replication options. Cassandra provides several strategies for managing replication of data; SimpleStrategy is the best strategy as long as your Cassandra deployment does not span across multiple data centers. The replication_factor value tells Cassandra how many copies of each piece of data are to be kept in the cluster; since we are only running a single instance of Cassandra, there is no point in keeping more than one copy of the data. In a production deployment, you would certainly want a higher replication factor; three is a good place to start.
A few things at this point are worth noting about CQL's syntax:
- It's syntactically very similar to SQL; as we further explore CQL, the impression of similarity will not diminish.
- Double quotes are used for identifiers such as keyspace, table, and column names. As in SQL, quoting identifier names is usually optional, unless the identifier is a keyword or contains a space or another character that will trip up the parser.
- Single quotes are used for string literals; the key value structure we use for replication is a map literal, which is syntactically similar to an object literal in JSON.
- Introduction to DevOps with Kubernetes
- 網(wǎng)上沖浪
- Verilog HDL數(shù)字系統(tǒng)設(shè)計入門與應(yīng)用實例
- STM32嵌入式微控制器快速上手
- 電腦上網(wǎng)輕松入門
- 中文版AutoCAD 2013高手速成
- 實戰(zhàn)Windows Azure
- EJB JPA數(shù)據(jù)庫持久層開發(fā)實踐詳解
- Moodle 2.0 Course Conversion(Second Edition)
- 歐姆龍PLC應(yīng)用系統(tǒng)設(shè)計實例精解
- 傳感器應(yīng)用技術(shù)
- AVR單片機C語言程序設(shè)計實例精粹
- ASP.NET 4.0 MVC敏捷開發(fā)給力起飛
- 谷物干燥節(jié)能供熱技術(shù)與裝備
- 博弈論與無線傳感器網(wǎng)絡(luò)安全