Previous | Table of Contents | Next

Page 591

Bonus
Day

Day 23

Oracle8: New Features

On June 24, 1997, Oracle Corporation formally announced the next major release of the Oracle RDBMS: Oracle8. This new release is one of the major components of Oracle's Network Computing Architecture. Oracle Corporation is emphasizing several new characteristics of the Oracle8 server, such as:

Page 592

NOTE
Oracle Corporation has stated that the Oracle8 Migration Tool can migrate an Oracle7 database (version 7.1, 7.2, or 7.3) to Oracle8. In addition, an application that currently works with an Oracle7 database will work properly with an Oracle8 database. Therefore, all the features of SQL and PL/SQL discussed throughout this book will continue to work in Oracle8.

Many of these new features are of primary interest to database administrators and system architects. However, this lesson will focus on new features of Oracle8 that are of interest to database designers and application developers. The material in this lesson is based on Oracle8 for Windows NT, version 8.0.2.0.1 Beta2.

Enhancement of Existing Datatypes and
Some New Datatypes

Oracle8 has increased the maximum size of some existing Oracle datatypes:

Page 593

In addition, a single table can now have up to 1,000 columns.

Two new datatypes, NCHAR and NCHAR VARYING, can be used with Oracle8. These datatypes can be used for national character sets that require more than one byte per character; this is needed for many Asian languages.

NOTE
The examples in this lesson were performed with SQL*Plus and SQL Worksheet.

Large Objects, or LOBs

Oracle8 provides much more support in the area of large objects. In fact, a new category of datatypes, called LOB, or Large Object, is introduced with Oracle8.

LOBs can be one of four datatypes:

There are several advantages to using LOBs. First, a LOB can accommodate 4GB or twice the capacity of the LONG or LONG RAW column. Second, a table can contain more than one LOB column, whereas it can contain only a single LONG or LONG RAW column. Also, the data stored in a LOB column is kept in a storage area separate from the table that contains the LOB column, resulting in better overall performance. Let's look at some examples of how these datatypes can be used.

Using BLOBs

You can think of the BLOB datatype as a new, improved version of the LONG RAW datatype. A BLOB column can store twice as much as a LONG RAW column. Unlike a LONG RAW column, an INSERT statement with a subquery may contain a BLOB column. Listing 23.1 is an example of the creation of a table that contains a BLOB column. The BLOB column is used to store a scanned image of a potential instructor's resume.

Listing 23.1. Creating a table that contains a BLOB column.

SQL> create table Instructor_Application (
  2  Application_Number number,
  3  Last_Name          varchar2(30),

                                                           continues

Page 594

Listing 23.1. continued

  4  First_Name         varchar2(30),
  5  MI                 varchar2(1),
  6  Resume             blob,
  7  Status             varchar2(30));

Table created.

Using CLOBs

The CLOB datatype is similar to the LONG datatype. Like the LONG datatype, the CLOB datatype is used for storing long strings. However, the CLOB datatype has twice the capacity of the LONG datatype—4GB instead of 2GB.

In Listing 23.2, you can see an example of how a CLOB column, named OCR_Resume, is added to the Instructor_Application table. The purpose of the OCR_Resume column is to store the text recognized by the scanning software after the resume has been scanned.

Listing 23.2. Altering a table to add a CLOB column.

SQL> alter table Instructor_Application add
  2  (OCR_Resume  clob);

Table altered.

SQL> update Instructor_Application
  2  set OCR_Resume = `Resume of A. Einstein - Born in Ulm, Germany in 1879'
  3  ;

1 row updated.

SQL> select OCR_Resume from Instructor_Application;

OCR_RESUME
--------------------------------------------------------------------------------
Resume of A. Einstein - Born in Ulm, Germany in 1879
ANALISIS
After the CLOB column has been added to the table, an UPDATE statement is used to set the value of OCR_Resume. A SELECT statement illustrates that the contents of OCR_Resume can be retrieved from the table.

Another important distinction between the CLOB and LONG datatypes is that there are fewer restrictions on referencing a CLOB column in a SQL statement. Refer to Listing 23.3 to see an example.

Previous | Table of Contents | Next

Используются технологии uCoz