query: update syncql tutorial to include delete statements
Change-Id: If3420148cb8f8d938af1ce0870f99572fa50ac25
diff --git a/tutorials/syncql-tutorial.md b/tutorials/syncql-tutorial.md
index 0f3047e..eb3a691 100644
--- a/tutorials/syncql-tutorial.md
+++ b/tutorials/syncql-tutorial.md
@@ -969,6 +969,102 @@
| 001003 |
+--------+
+### Executing Delete Statements
+
+In addition to select statements, syncql supports delete statements. (Insert and Update statements are planned.)
+
+The delete statement takes the form:
+ delete from <table> [<where-clause>] [<limit-clause>]
+
+The where and limit clauses for delete are identical to the where and limit caluses for select.
+
+To delete all k/v pairs in a table, leave off the where and limit clauses:
+
+ ? delete from Customers;
+ +-------+
+ | Count |
+ +-------+
+ | 9 |
+ +-------+
+
+Exactly one row with exactly one "Count" column is always returned from an execution of the delete statement. The value of the column is the number of k/v paris deleted. In this case, all nine k/v pairs in the Customers table have been deleted. To verify this, select all entries in the Customers table:
+
+ ? select k from Customers;
+ +---+
+ | k |
+ +---+
+ +---+
+
+Let's restore the entries by executing make-demo again.
+ ? make-demo;
+ Demo tables created and populated.
+
+Now, let's use the where clause to delete only invoice entries:
+? delete from Customers where Type(v) like "%.Invoice";
+
+ +-------+
+ | Count |
+ +-------+
+ | 7 |
+ +-------+
+
+The seven invoice entries have been deleted. A select reveals the delete indeed deleted what we expected.
+
+ ? select k, Type(v) from Customers;
+ +-----+--------------------------------------------+
+ | k | Type |
+ +-----+--------------------------------------------+
+ | 001 | v.io/x/ref/cmd/sb/internal/demodb.Customer |
+ | 002 | v.io/x/ref/cmd/sb/internal/demodb.Customer |
+ +-----+--------------------------------------------+
+
+Lastly, let's delete all Customers where the address is not Palo Alto:
+
+ ? delete from Customers where v.Address.City <> "Palo Alto";
+ +-------+
+ | Count |
+ +-------+
+ | 1 |
+ +-------+
+
+Since customer 001, John Smith, is in Palo Alto, the delete statement did not delete him. A select reveals Bat Masteson, who resides in Collins, IA, was indeed deleted.
+
+ ? select k from Customers;
+ +-----+
+ | k |
+ +-----+
+ | 001 |
+ +-----+
+
+Let's restore the tables before we try the limit clause on a delete:
+
+ ? make-demo;
+ Demo tables created and populated.
+
+Now, let's delete Invoice entries again, but put a limit of two on the statement:
+
+ ? delete from Customers where Type(v) like "%.Invoice" limit 2;
+ +-------+
+ | Count |
+ +-------+
+ | 2 |
+ +-------+
+
+A select reveals only the first two invoices (in ascending key order) have been deleted ("001001" and "001002"):
+
+ ? select k from Customers;
+ +--------+
+ | k |
+ +--------+
+ | 001 |
+ | 001003 |
+ | 002 |
+ | 002001 |
+ | 002002 |
+ | 002003 |
+ | 002004 |
+ +--------+
+
Congratulations! You've finished the syncQL tutorial. Don't forget to proceed to the [teardown](#teardown) steps to clean up! Also, check out the brief introduction to executing syncQL queries from a Go program.
## Teardown