Chapter 1. Elements of SQL

SQL was developed to provide easy access to relational databases, so it is able to perform the following kinds of actions:

  • Querying data from a database

  • Inserting data into a database

  • Deleting data from a database

  • Creating and manipulating database objects

  • Controlling access to the database

Strictly speaking, SQL is not a language at all, but rather a means of conveying instructions to the Oracle database. It differs from traditional programming languages in several important ways:

  • SQL provides automatic navigation to data.

  • SQL operates on sets of data, rather than on individual data elements.

  • SQL is declarative, not procedural, and does not provide procedural control.

  • SQL programming is done at the logical level; there is little need to deal with the details of implementation.

Simply put, when programming in SQL you tell Oracle what you want to do, but not how it should be done. However, this approach can be both a blessing and a curse. Consider the following SQL statement:

SELECT ename, deptno, sal, comm
FROM scott.emp
WHERE hiredate > '01-JAN-00';

This simple SQL statement tells the database to display a list consisting of name (ename), department number (deptno), salary (sal), and commission (comm) for each employee hired after January 1, 2000. Such a program might have taken hundreds of lines of code in an "old style" procedural language, but takes only three lines in SQL. At the same time, however, Oracle is not always too smart about how it retrieves ...

Get Oracle SQL: the Essential Reference 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.