The goal of this chapter is to introduce you to all the major SQL commands and show some of the basic usage patterns. The first time you read through this chapter, don’t feel you need to absorb everything at once. Get an idea of what structures the database supports, and how they might be used, but don’t feel that you need to memorize the details of every last command.
For people just getting started, the most important commands are CREATE
TABLE, INSERT, and
SELECT. These will let you create a
table, insert some data into the table, and then query the data and display
it. Once you get comfortable with those commands, you can start to look at
the others in more depth. Feel free to refer back to this chapter, or the
command reference in Appendix C. The command reference
provides detailed descriptions of each command, including some of the more
advanced syntax that isn’t covered in this chapter.
Always remember that SQL is a command language. It
assumes you know what you’re doing. If you’re directly entering SQL commands
through the sqlite3 application, the
program will not stop and ask for confirmation before processing dangerous
or destructive commands. When entering commands by hand, it is always worth
pausing and looking back at what you’ve typed before you hit return.
If you are already reasonably familiar with the SQL language, it should be safe to skim this chapter. Much of the information here is on the SQL language in general, but there is some information about the specific dialect of SQL that SQLite recognizes. Again, Appendix C provides a reference to the specific SQL syntax used by SQLite.