From 4bd7c89e667b733e138a198a4e803b5dcbd1faf3 Mon Sep 17 00:00:00 2001 From: Gabor Szabo Date: Fri, 16 Aug 2024 09:42:44 +0300 Subject: [PATCH] add --- sqlite/examples/update.sql | 18 ++++++++++++++++++ sqlite/intro.md | 15 +++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 sqlite/examples/update.sql diff --git a/sqlite/examples/update.sql b/sqlite/examples/update.sql new file mode 100644 index 00000000..0c1b52f9 --- /dev/null +++ b/sqlite/examples/update.sql @@ -0,0 +1,18 @@ +CREATE TABLE people ( + name TEXT, + grade INTEGER +); + +INSERT INTO people (name, grade) VALUES ('Joe', 40); +INSERT INTO people (name, grade) VALUES ('Jane', 60); +SELECT * from people; +SELECT ""; + +UPDATE people SET grade = 44 WHERE name = "Joe"; +SELECT * from people; +SELECT ""; + +UPDATE people SET grade = (SELECT grade FROM people WHERE name = "Joe") + 1 WHERE name = "Joe"; +SELECT * from people; +SELECT ""; + diff --git a/sqlite/intro.md b/sqlite/intro.md index ccfacda6..23edc9a5 100644 --- a/sqlite/intro.md +++ b/sqlite/intro.md @@ -166,8 +166,23 @@ Meaning of life?|42 ## Transactions {id: transactions} +![](examples/transaction.sql) + ## PRAGMA {id: pragma} [PRAGMA](https://sqlite.org/pragma.html) +## UPDATE +{id: update} + +![](examples/update.sql) + + + + +* TODO: loading a large CSV file into the database and running queries. +* TODO: creating a multi-tabe databas, dumping it and then loading it and running queries against it. +* TODO: FOREIGN KEY - cascading deletition? + +