SQL Views   «Prev  Next»
Lesson 5 Selecting from a view
Objective Select from a view in order to refine your results.

Selecting Data from SQL View

Remember that you query a view for the information it represents. You can also apply standard SELECT statements to the view. In other words, when you select from the view, you can further refine the results you retrieve.
For example, if you wanted to query the MyView view but only return the rows with a Lastname starting with "W," you could do so with the following statement:

SELECT * FROM MyView
WHERE  Lastname 
LIKE 'W%'

The view narrows the results to only those in the state of Utah, and the SELECT statement then further narrows the results, limiting them to rows with an appropriate Lastname.
Find the strength within yourself to understand what views are all about. In the next lesson, you will get the details about how you create and reuse queries.

SQL Programming

Data Dictionary

The structure of a relational database is stored in the data dictionary of the database. The data dictionary is made up of a set of relations that are identical in properties to the relations used to hold data. They can be queried using the same tools used to query data-handling relations. No user can modify the data dictionary tables directly. However, (DML) data manipulation language commands that create, modify, and destroy database structural elements work by modifying rows in data dictionary tables.
You will typically find the following types of information in a data dictionary:
  1. Definitions of the columns that make up each table
  2. Integrity constraints placed on relations
  3. Security information (which user has the right to perform which operation on which table)
  4. Definitions of other database structure elements, such as views and user-defined domains
When a user attempts to access data in any way, a relational DBMS first goes to the data dictionary to determine whether the database elements the user has requested are actually part of the schema. In addition, the DBMS verifies that the user has the access right to whatever he or she is requesting. When a user attempts to modify data, the database management system goes to the data dictionary to look for integrity constraints that may have been placed on the relation. If the data meet the constraints, then the modification is permitted. Otherwise the DBMS returns an error message and does not make the change. Because all access to a relational database is through the data dictionary, relational database management systems are said to be data dictionary driven. The data in the data dictionary are known as metadata, which is data about the data.