Cassandra Query Language (CQL)
ℹ️ For technical support, please contact us via email.
Insert and Load Data
✅ Manually insert a single row into the table using an INSERT
statement.
video_id | added_date | title |
---|---|---|
36b8bac0-6260-11ea-ac4c-87a8af4b7ed0 | 2020-03-09 | Foundations of DataStax Enterprise |
Solution
INSERT INTO videos (video_id, added_date, title)
VALUES (36b8bac0-6260-11ea-ac4c-87a8af4b7ed0, '2020-03-09', 'Foundations of DataStax Enterprise');
✅ Use a SELECT
statement to retrieve your row from the table.
Solution
SELECT * from videos;
✅ Insert another row into the table.
video_id | added_date | title |
---|---|---|
95fe9800-2c2f-11b2-8080-808080808080 | 2020-01-20 | Cassandra Data Modeling |
Solution
INSERT INTO videos (video_id, added_date, title)
VALUES (95fe9800-2c2f-11b2-8080-808080808080, '2020-01-20', 'Cassandra Data Modeling');
✅ Retrieve all rows from the table.
SELECT * from videos;
✅ Delete all previously inserted rows from the table using the TRUNCATE
statement and verify that the table is empty.
Solution
TRUNCATE videos;
SELECT * from videos;
✅ Use the COPY
command to import data into your videos
table.
COPY videos(video_id, added_date, title)
FROM '/workspace/ds201-lab02/data-files/videos.csv'
WITH HEADER=TRUE;
✅ Retrieve all rows from the table to verify that the table loaded correctly.
SELECT * from videos;