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? + +