Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
1Activity
0 of .
Results for:
No results containing your search query
P. 1
chapte~8

chapte~8

Ratings: (0)|Views: 1 |Likes:
Published by Arsalan Ahmed
chapte~8
chapte~8

More info:

Published by: Arsalan Ahmed on Dec 26, 2012
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

12/12/2014

pdf

text

original

 
SchemaManager forViews,Synonyms,and Sequences
T
his chapter explores further ways to use SchemaManager. Here you learn how to create and modify views,Synonyms, and sequences.The Schema Manager substitutes for handwritten SQL code.You can view the commands generated by the SchemaManager and even record them for later use.If a task described here has an equivalent SQL command, theCommand Reference section of this book contains a cross-reference to the command. Watch for the See ReferenceSection icon in the margin.Chapter 13 contains complete instructions for views,Synonyms, and sequences using the SQL commands.
Views
Views have one primary purpose: to rearrange the way yousee a Table, a portion of a Table, or a group of Tables withoutactually creating any copies of the underlying data. Viewsenable you to use the data in more convenient “packaging.”For example, a certain Table contains all valid orders for everycustomer. You could create a view that shows you the validorders for a single customer and reuse this view whendisplaying data to your customer on your Web site.
Cross-ReferenceSeeReferenceSection
88
CHAPTER
3 3 3 3
In This Chapter
Using SchemaManager forcreating viewsCreating private andpublic SynonymsSetting up sequences
3 3 3 3
 
188
Chapter 8
3
Schema Manager for Views, Synonyms, and Sequences
Chapter 24 shows how to create views based on Objects (Object views).You can use a view anywhere you can use a Table. You can use views in the
FROM
clause of your SQL query or even in an
INSERT
,
UPDATE
, or
DELETE
command.
Modifying data using views
When you update data using a view, you actually update the underlying Table’sdata. This condition also applies when you insert or delete from a view.You cannot use some kinds of views for modifying data:
3
Views with set operators such as
INTERSECT
,
UNION
, and
MINUS
3
Views with
GROUP BY
,
connect BY
, or
START WITH
clauses
3
Views with group functions such as
AVG
,
SUM
, or
MAX
3
Views using the
DISTINCT
function
3
Views which join Tables (with some exceptions)You can create views that join several Tables and still allow the update of one Table.The updateable Table must have a unique Index on at least one Column in the joined Table. Even then, all Columns in the view are not updateable. To determinewhich columns, if any, are updateable, query the Data Dictionary view called
USER_UPDATABLE_COLUMNS
. This view displays the updateable Columns.For example, if you create a view named
TANK_ANIMALS_VIEW
that joins two Tables,the following SQL
SELECT
command shows which Columns you can use forupdating:
SELECT COLUMN_NAME, UPDATABLEFROM USER_UPDATABLE_COLUMNSWHERE TABLE_NAME = ‘TANK_ANIMALS_VIEW’;
Use views to restrict the kind of data inserted or updated into the underlying Tablewith the
WITH CHECK OPTION
parameter. The
WITH CHECK OPTION
states all datamodified through the view must fit within the view.
Creating a new view
CREATE View
This section describes how to create a view using the Schema Manager.
SeeReferenceSectionCross-Reference
 
189
Chapter 8
3
Views
To illustrate the following steps, let’s create a view in the
SEAPARK
Schema:
1.Start the Schema Manager and log in as the DBA.2.Click Object
Á
Create.
A small pop-up menu lists Objects that you can create.
3.Click View.
The Create View window appears as shown in Figure 8-1.
Figure 8-1:
Schema Manager createsviews here.
4.Type in the name of the view in the Name box.5.Select the Schema in the Schema box.6.Type in a query in the Query textbox.
At this point, you must write a validSQL query. As an example, a new view called
CARETAKER_ANIMAL_VIEW
iscreated. It merges the two Tables:
TANK
and
AQUATIC_ANIMAL
. (See Figure 7-1in Chapter 7 for a database diagram showing the relationship of these Tables.)The query assumes the User logged in to Oracle8 is the name of the
CARETAKER
. The query follows:
SELECT TANK_NAME, ANIMAL_NAME, BIRTH_DATEFROM TANK T , AQUATIC_ANIMAL AWHERE CHIEF_CARETAKER_NAME = USERAND T.TANK_NO = A.TANK_NO
Figure 8-2 shows the appearance of the Create View window.

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->