Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Create a new keyspace with the name 'cqlintro' and the SimpleStrategy as the
- -- replication strategy and a replication factor of 1. SimpleStrategy is fine for
- -- development or just playing but once you're setting up a keyspace in production
- -- be sure to switch to NetworkTopologyStrategy!
- CREATE KEYSPACE cqlintro
- WITH REPLICATION = {'class':'SimpleStrategy', 'replication_factor':1};
- -- Start using the new keyspace as the default keyspace.
- -- You don't need to do this part as you can just refer to tables with the full
- -- name of 'cqlintro.table_name', this just makes it easier.
- USE cqlintro;
- CREATE TABLE company (
- company_id INT,
- name VARCHAR,
- PRIMARY KEY (company_id)
- );
- INSERT INTO company (company_id, name) VALUES (1, 'ShoreTel');
- INSERT INTO company (company_id, name) VALUES (2, 'Erik''s Company');
- CREATE TABLE employee (
- company_id INT,
- employee_id INT,
- first_name VARCHAR,
- last_name VARCHAR,
- PRIMARY KEY ((company_id), employee_id)
- );
- INSERT INTO employee (company_id, employee_id, first_name, last_name) VALUES (1, 1, 'John', 'Doe');
- INSERT INTO employee (company_id, employee_id, first_name, last_name) VALUES (1, 2, 'Jane', 'Doe');
- INSERT INTO employee (company_id, employee_id, first_name, last_name) VALUES (2, 3, 'Erik', 'Davidson');
- INSERT INTO employee (company_id, employee_id, first_name, last_name) VALUES (2, 4, 'Joe', 'Cool');
- -- Returns all the employees for "Erik's Company"
- SELECT * FROM employee WHERE company_id = 2;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement