-
Notifications
You must be signed in to change notification settings - Fork 1k
Expand file tree
/
Copy pathschema.sql
More file actions
50 lines (40 loc) · 984 Bytes
/
schema.sql
File metadata and controls
50 lines (40 loc) · 984 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
CREATE TABLE tbl(a INTEGER PRIMARY KEY, b TEXT, c TEXT, d TEXT, e INTEGER);
CREATE VIRTUAL TABLE tbl_ft USING fts5(b, c UNINDEXED, content='tbl', content_rowid='a');
CREATE VIRTUAL TABLE ft USING fts5(b);
CREATE TRIGGER tbl_ai AFTER INSERT ON tbl BEGIN
INSERT INTO tbl_ft(rowid, b, c) VALUES (new.a, new.b, new.c);
END;
INSERT INTO tbl VALUES(1, 'xx yy cc', 't', 'a', 11);
INSERT INTO tbl VALUES(2, 'aa bb', 't', 'a', 22);
INSERT INTO ft VALUES('xx cc');
INSERT INTO ft VALUES('cc bb');
CREATE TABLE weather (
id INTEGER PRIMARY KEY AUTOINCREMENT,
latitude REAL NOT NULL,
longitude REAL NOT NULL
);
CREATE VIRTUAL TABLE weather_rtree USING rtree(
id,
min_lang, max_long,
min_lat, max_lat
);
CREATE TRIGGER weather_insert
AFTER INSERT
ON weather BEGIN
INSERT INTO
weather_rtree (
id,
min_lang,
max_long,
min_lat,
max_lat
)
VALUES
(
NEW.id,
NEW.latitude,
NEW.latitude,
NEW.longitude,
NEW.longitude
);
END;