Create table "actors"
Our last table will store information about movie actors as shown below. This table with single-row partitions and a composite partition key is for you to define.
first_name | last_name | dob |
---|---|---|
Johnny | Depp | 1963-06-09 |
Anne | Hathaway | 1982-11-12 |
✅ Create the table:
Solution
CREATE TABLE IF NOT EXISTS actors (
first_name TEXT,
last_name TEXT,
dob DATE,
PRIMARY KEY ((first_name, last_name))
);
✅ Insert the rows:
Solution
INSERT INTO actors (first_name, last_name, dob)
VALUES ('Johnny', 'Depp', '1963-06-09');
INSERT INTO actors (first_name, last_name, dob)
VALUES ('Anne', 'Hathaway', '1982-11-12');
✅ Retrieve one row:
Solution
SELECT * FROM actors
WHERE first_name = 'Johnny'
AND last_name = 'Depp';
✅ Retrieve all rows:
Solution
SELECT * FROM actors;