Java Reference
In-Depth Information
Appendix B
SQL
SQL is an industry-wide, standard set of relational commands that allows users to both define and manipulate data
in a database. SQL has been adopted as the common interface for relational data definition and data manipulation
functions on all major relational DBMS (Database Management Systems).
This chapter will introduce the reader to SQL and show how SQL commands can be used within a Java
application.
After finishing this chapter, you will understand:
The most commonly used SQL commands and their syntax
The major SQL components
After finishing this chapter, you will be able to:
Create schemas, tables, views, and indexes
Manipulate and retrieve data using SQL
SQL and Relational Database Concepts
SQL uses schemas (also referred to as collections) and tables to store data. You can think of a schema as a folder.
(In actuality, a schema is also comprised of journals, a catalog, and cross reference tables. However, these are things a
beginning Java programmer does not have to worry about.) Database analysts use schemas to group tables that hold
related data. The schema and its tables correspond to what we have been referring to as a database. SQL statements
can be used in application programs to both create these SQL constructs and access and manipulate the data stored
within. Using SQL within a program provides a big advantage because SQL statements reference the universally
accepted SQL objects (e.g., schemas and tables) regardless of what the individual DBMSs call these objects. Because
of this, the Java developers did not include any data manipulation keywords in the Java language. Instead they
supplied Java classes (such as the Statement and ResultSet classes) to facilitate the use of SQL.
A table is a two-dimensional array of data in rows and columns. Rows are often referred to as records and
columns as fields. Individual pieces of data are stored in a single column of a single row. If you are familiar with
spreadsheets, this is comparable to a spreadsheet cell.
Within Java applications, SQL statements are passed to a Statement object for execution. For the purposes of
initially learning SQL, all examples will only show the SQL commands and required syntax. The Database Access
chapter will show how to integrate the commands into a Java class.
 
Search WWH ::




Custom Search