Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
34 lines (23 sloc) 1.2 KB
\chapter{Exercise 10: Updating Complex Data}
In the last exercise I had you do a subquery in the \ident{UPDATE}, and now
you'll use it to change all the pets I own to be named "Zed's Pet".
\begin{code}{ex10.sql}
<< d['code/ex10.sql|pyg|l'] >>
\end{code}
This is how you update one table based on information from another table.
There's other ways to do the same thing, but this way is the easiest to
understand for you right now.
\section{What You Should See}
As usual, I use my little \file{code.sql} to reset my database and then output
nicer columns with \program{sqlite3 -header -column -echo}.
\begin{code}{ex10.sql Output}
<< d['code/ex10.sh-session|pyg|l'] >>
\end{code}
\section{Extra Credit}
\begin{enumerate}
\item Write an \ident{SQL} that only renames dead pets I own to "Zed's Dead Pet".
\item Go to the \href{http://www.sqlite.org/lang.html}{SQL As Understood By SQLite}
page and start reading through the docs for \ident{CREATE TABLE}, \ident{DROP TABLE}, \ident{INSERT}, \ident{DELETE}, \ident{SELECT}, and \ident{UPDATE}.
\item Try out some of the interesting things you find in these docs, and take notes
on things you don't understand so you can research them more later.
\end{enumerate}