-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommands.txt
More file actions
19 lines (19 loc) · 872 Bytes
/
commands.txt
File metadata and controls
19 lines (19 loc) · 872 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
CREATE TABLE animals (name VARCHAR(20), kind VARCHAR(8), years INTEGER) PRIMARY KEY (name, kind);
INSERT INTO animals VALUES FROM ("Joe", "cat", 4);
INSERT INTO animals VALUES FROM ("Spot", "dog", 10);
INSERT INTO animals VALUES FROM ("Snoopy", "dog", 3);
INSERT INTO animals VALUES FROM ("Tweety", "bird", 1);
INSERT INTO animals VALUES FROM ("Joe", "bird", 2);
SHOW animals;
dogs <- select (kind == "dog") animals;
old_dogs <- select (age > 10) dogs;
cats_or_dogs <- dogs + (select (kind == "cat") animals);
CREATE TABLE species (kind VARCHAR(10)) PRIMARY KEY (kind);
INSERT INTO species VALUES FROM RELATION project (kind) animals;
a <- rename (aname, akind) (project (name, kind) animals);
common_names <- project (name) (select (aname == name && akind != kind) (a * animals));
answer <- common_names;
SHOW answer;
WRITE animals;
CLOSE animals;
EXIT;