Easy SQL Queries Are in Reach

By Bill Harper, published Aug 28, 2007
Published Content: 9  Total Views: 1,365  Favorited By: 0 CPs
Rating: 3.2 of 5
Structured Query Language or SQL is an easy to learn computer language for accessing and manipulating database systems. This is a language that works with programs such as Microsoft Access, DB2, Informix, and Oracle SQL Plus.

There are different versions of SQL; for example, a query written for Microsoft Access is different then a query written for Oracle, even though they produce identical results. To meet American National Standards Institute guidelines, all SQL queries include the SELECT, FROM and WHERE clauses.

There are several SQL editing and reporting packages available including Microsoft Access and Crystal Reports; however, for this tutorial, the query will be written for Oracle SQL Plus. SQL Plus is a command line interface that is bundled with the Oracle Database Client and Server. It is interactive or script driven and is used by database administrators and developers to access Oracle databases.

A table, the basic unit for a relational database, is a set of related information. Tables are then further separated into columns that hold a specific data type within the table. For example a data table of employee information would have data in columns of employee number, first name, last name and telephone number.

The first step to understanding how to use SQL to get information is to know what is available in a database. A schema is a listing of all of the data that is in a database and includes the table layout and a diagram that shows the relationship between the data.

In Oracle SQL plus, a user can see what columns are available by typing the command 'desc' and the name of a specific table. In this tutorial, one of the tables used is the 'employee_information table which has five columns. In the example below, entering DESC employee_information at the command line produces the following result.

SQL> DESC employee_information

EMP_NB

FIRST_NAME

LAST_NAME

TELEPHONE_NB

HOME_TOWN

There are three clauses that make up a SQL query: the 'SELECT'clause; the 'FROM' clause; and the 'WHERE' clause. Each clause provides the query with specific information on the data that is to be pulled.

Easy SQL Queries Are in Reach
Easy SQL Queries Are in Reach

Example One is a screen shot that shows the difference between 'SELECT *' and defining columns in the SQL 'SELECT' clause

Credit: Bill Harper

Copyright: Bill Harper

Takeaways
  • Structured Query Language is used to access and manipulate data
  • The three important clauses in SQL are 'SELECT', 'FROM', and 'WHERE'
Did You Know?
There are many different versions of the SQL language and most SQL database programs have their own proprietary extensions in addition to the SQL standard. All SQL variations must support the same major keywords in a similar manner.
Comments
Type in Your Comments Below - (1000 characters left)
Your name:

Submit your own content on this or any topic. Get started »
Most Commented On