Skip to content
Amos Kong edited this page Nov 7, 2019 · 11 revisions

Lightweight transactions quickstart

Start the container:

docker run --name lwt --hostname -d scylladb/scylla-nightly:lwt --experimental 1

Connect with cqlsh:

docker exec -it lwt cqlsh

Create and use a keyspace:

CREATE KEYSPACE lwt WITH replication = { 'class': 'SimpleStrategy', 'replication_factor': 1} and durable_writes=true;

USE lwt;

Create a basic table with two columns: employee and task.

CREATE TABLE tasks (employee_id int, task_id int, primary key (employee_id));

Try to assign a task to employee:

INSERT INTO tasks (employee_id, task_id) VALUES (1, 1) IF NOT EXISTS;

Try again and see that the task if an employee already has an assigned task it is not assigned a new task:

INSERT INTO tasks (employee_id, task_id) VALUES (1, 2) IF NOT EXISTS;

Change the assignment:

UPDATE tasks set task_id = 2 WHERE employee_id = 1 IF task_id = 1;

Complete the task:

DELETE FROM tasks WHERE employee_id = 1 IF EXISTS;


Clone this wiki locally
You can’t perform that action at this time.