Welcome to our Cassandra CQL (Cassandra Query Language) tutorial! This guide is designed to help you understand and master Cassandra, a powerful, open-source, and distributed database management system. Let's dive in! 🎯
Cassandra Query Language (CQL) is a high-level, SQL-like language used to interact with Apache Cassandra, a NoSQL database. It simplifies the process of managing and querying data, making it easy for developers to work with this powerful database system.
To get started with CQL, you'll need a running Cassandra instance. If you don't have one, follow the Cassandra installation guide. Once installed, you can connect to Cassandra using the cqlsh command in your terminal.
A keyspace in Cassandra is similar to a database in SQL. To create a keyspace, use the CREATE KEYSPACE command:
CREATE KEYSPACE mykeyspace WITH replication = {'class':'SimpleStrategy', 'replication_factor':1};Tables in Cassandra are called columns families. To create a table, use the CREATE TABLE command:
CREATE TABLE mykeyspace.mytable (
id UUID PRIMARY KEY,
name text,
age int
);💡 Pro Tip: Use the UUID type for unique identifiers, as it provides a time-based system that's ideal for Cassandra.
To insert data into a table, use the INSERT command:
INSERT INTO mykeyspace.mytable (id, name, age) VALUES (UUID(), 'John Doe', 30);To query data, use the SELECT command:
SELECT * FROM mykeyspace.mytable WHERE id = UUID('your_uuid');SELECT, WHERE, AND, OR, IN, NOT, and more.What does CQL stand for?
Stay tuned for our upcoming lessons on advanced CQL topics! If you have any questions, feel free to ask. Happy learning! 📝