Prev | Current Page 269 | Next

Richard Niemiec

"Oracle Database 10g Performance Tuning Tips & Techniques"

In the following listing, the CUSTOMER table is
created as a relational table, using only the normally provided datatypes:
create table CUSTOMER
(Name VARCHAR2(25) primary key,
Street VARCHAR2(50),
City VARCHAR2(25),
State CHAR(2),
Zip NUMBER);
If you want to create another table or application that stores information about people and
addresses, you may choose to create the ADDRESS_TY datatype. However, for consistency, that
datatype should be applied to the CUSTOMER table as well. The following examples will use the
ADDRESS_TY datatype created in the preceding section.
To create an object view, use the create view command. Within the create view command,
specify the query that will form the basis of the view. The code for creating the CUSTOMER_OV
object view on the CUSTOMER table is shown in the following listing:
create view CUSTOMER_OV (Name, Address) as
select Name,
ADDRESS_TY(Street, City, State, Zip)
from CUSTOMER;
The CUSTOMER_OV view will have two columns: the Name and the Address columns (the latter
is defined by the ADDRESS_TY datatype). Note that you cannot specify object as an option within
the create view command.
Several important syntax issues are presented in this example. When a table is built on existing
abstract datatypes, you select column values from the table by referring to the names of the columns
(such as Name) instead of their constructor methods. When creating the object view, however,
you refer to the names of the constructor methods (such as ADDRESS_TY) instead.


Pages:
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281
news news news news news