Author Topic: SQL 101: Why WHERE Matters  (Read 1331 times)

Mike

  • Administrator
  • Hero Member
  • *****
  • Posts: 1998
    • View Profile
SQL 101: Why WHERE Matters
« on: March 29, 2012, 05:02:23 PM »
SQL 101: Why WHERE Matters
29 March 2012, 3:53 pm

Source: Oracle Magazine - Most Recent

Part 4 in a series on the basics of the relational database and SQL   
Part 3 in this series, ďGetting Answers with SELECT StatementsĒ (Oracle Magazine, January/February 2012), introduced the anatomy of a SELECT statement (or query) and the importance of ascertaining which tables contain data of interest. Now that youíre familiar with a SELECT statementís basic functionality, you can start filtering your data to limit the output in meaningful ways. The WHERE clause enables you to narrow the scope of the data a SELECT statement retrieves (or fetches). WHERE, and its associated comparison and logical operators, are the focus of this article.

To try out the examples in this and subsequent articles in the series, you need access to an Oracle Database instance. If necessary, download and install an Oracle Database edition for your operating system. I recommend installing Oracle Database, Express Edition.

If you install the Oracle Database software, choose the installation option that enables you to create and configure a database. A new database, including sample user accounts and their associated schemas, will be created for you. (Recall from Part 1 of this series that a schema is typically a grouping of objects, such as tables, that serve a similar business function.) SQL_101 is the user account youíll use for the examples in this article; itís also the schema in which you will create database tables and other objects.

When the installation process prompts you to specify schema passwords, enter and confirm passwords for SYS and SYSTEM and make a note of them. Finally, whether you installed the database software from scratch or have access to an existing Oracle Database instance, download and unzip the SQL script and run it to create the example tables for the SQL_101 schema.

The SQL queries in this article are executed against tables in the SQL_101 schema with the SQL*Plus tool.

Full Article: http://www.oracle.com/technetwork/issue-archive/2012/12-mar/o22sql-1494267.html
« Last Edit: March 30, 2012, 08:32:57 AM by Mike »