An Introduction to SQL

Note

SQL keywords are case-insensitive, meaning that SELECT and select are treated exactly the same. Depending on your database, however, table and column names may or may not be case-insensitive. In addition, the space between words in a SQL statement is unimportant. You can have a newline after each word, several spaces, or just a single space. Throughout this book I use the convention of placing SQL keywords in all capitals and separating single SQL statements across multiple lines for readability.

How do you get the data into the database? And how do you get it out once it is in there? All major databases support a standard query language called Structured Query Language (SQL). SQL is not much like any programming language you might be familiar with. Instead, it is more of a structured English for talking to a database. A SQL query to the album titles from your database would look like this:

SELECT title FROM albums

In fact, much of the simplest database access comes in the form of equally simple SQL statements. Most of what you will do in SQL boils down to four SQL commands: SELECT, INSERT, UPDATE, and DELETE. You can issue SQL statements in several ways. The simplest, quickest way is through a SQL command-line tool. Each database engine comes with its own. Throughout most of this book, however, you will send your SQL as Java strings to JDBC methods.

Note

I should also make a couple of other syntactic notes. First, the single quotation mark (') is used ...

Get Database Programming with JDBC & Java, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.