Chapter 4. Database Objects

The object-oriented paradigm for computer programming languages was developed at Xerox PARC in the 1970s. Languages such as Smalltalk, Eiffel, and C++ were among the first to allow programmers to use objects. With the release of Oracle8, object-oriented features became available within the Oracle database. In most object-oriented programming languages, objects are instantiated from a class. The same is true in Oracle, but the nomenclature is a little different. In Oracle, a class is known as an object type, and it's from an object type that actual database objects are instantiated. Object types may contain attributes defined using the built-in Oracle types such as VARCHAR2 and NUMBER, and they may also contain attributes defined using other user-defined object types.

In Chapter 2 you saw how to create database tables, PL/SQL procedures, and PL/SQL functions. You will recall that table columns and PL/SQL variables may be defined using the built-in Oracle types. Oracle's object support also allows you to define columns and variables using object types. This is useful because it allows you to define columns that should contain composites of the built-in types. For example, suppose you needed to store an address that is made up of a street, city, state, and zip code. You could create separate columns in a table to store each of those address elements, but what if you needed to store another address in a different table? You could redefine those same columns ...

Get Java Programming with Oracle SQLJ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.