Skip to content

Latest commit

 

History

History
100 lines (77 loc) · 2.35 KB

File metadata and controls

100 lines (77 loc) · 2.35 KB
Tables with Single-Row Partitions in Apache Cassandra® ℹ️ For technical support, please contact us via email or LinkedIn.
⬅️ Back Step 7 of 9 Next ➡️
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;
⬅️ Back Next ➡️