Cassandra is a database with its own language for query called Cassandra Query Language (CQL). It’s a declarative language for communicating with Cassandra–developers use CQL commands to write and read data from the database.
CQL’s easy API offers an abstraction layer that helps keep Cassandra’s internal storage structure as well as details about its implementation hidden. The native syntaxes used for collection as well as other commonly used encodings are included.
Developers are able to communicate with Cassandra tool by using Cassandra’s CQL Shell interface, also known as cqlsh. It is located in the command prompt of the node. CQLSH is used to create keyspaces and tables, modify them and data, as well as to make changes to the data table data, insert tables and query them, and many more.
Comparing CQL against SQL
As we mentioned before due to their many similarities developers who have SQL previous experience will be able to quickly get started in CQL.
Like SQL, CQL stores data in tables that contain columns and rows. A lot of the actions and implementations are exactly similar, for example, retrieving all rows of tables, and the way the rights as well as resources for entities can be managed. If you are proficient on SQL statements like SELECT UPDATE, INSERT AND DELETE CQL will be an absolute quick and easy process.
There are some distinctions. For instance in SQL any column can be used within the WHERE clause. However, in CQL only those columns specifically defined as primary keys can be utilized as restricting columns. Furthermore, each query has to be able to define a partition key at a minimum CQL.
CQL’s most popular data types
CQL has a variety of available data types built into the program. Let’s look at a few of the most important types.
String types
Two types of data are used to depict text. One of them such as text or varchar can be used to make an UTF-8-character string. This is the latest popular text standard, which supports interna. To deal with data that is using ASCII formatting, CQL also includes the ASCII type.
Numeric types
Numeric types used in CQL are like those used similar to those found in Java along with other programming languages. These include decimals, integers floating-point numbers, and decimal places.
Types of date and time
CQL offers data types such as dates times, date ranges timingstamps, length (in the months and days as well as nanoseconds).
Geo-spatial Types
Data types for handling geospatial and spatial search are available. These types can search and index latitude and longitude data and shape data, as well as points and shapes.
Types of collection
CQL supports collections, which allow for multiple values to be stored in one column. You can use collections in order to save or normalize smaller amounts of data like tags, phone numbers or addresses. Collections aren’t suitable for data that is likely to expand unbounded like every event for a specific user. In such cases, it is better to consider a table with clustering columns.
Other CQL types of data
There are a variety of other types of data used to deal with specific situations. For instance, CQL includes the blob type that stores binary data, boolean to store the true and false value and counter for defining counter columns. Additionally, it has distinct identifiers.