Page 51
Oracle has quite a few built-in functions specifically for manipulating DATE values and expressions. You'll see some examples of these functions on Day 7. The DATE datatype enables you to store dates in the range of January 1, 4712 B.C., to December 31, 4712 A.D. Oracle uses the default format of DD-MMM-YY for entering and displaying dates.
As mentioned earlier, you must use Oracle's LONG datatype to store more than 2,000 characters in a single column. A LONG column can accommodate up to 2GB of characters. As with the VARCHAR2 datatype, the Oracle RDBMS is also efficient in its use of the LONG datatype; it will allocate only the storage that is needed to store each column value. However, you will face a number of restrictions on the use of LONG columns in SQL. You can't use Oracle functions or operators to search or modify the contents of a LONG column. If you try to search a LONG column, Oracle returns an error. In a sense, you can think of a LONG column as a large container into which you can store or retrieve databut not manipulate it.
NOTE |
Remember: You can have only one LONG column per table. |
As you're probably aware, most databases provide for the storage of binary large objects (BLOBs). BLOBs include documents, graphics, sound, videoactually, any type of binary file you can think of. The Oracle LONG RAW datatype is designed for BLOB storage.
When you want to associate a BLOB with a "normal" row, two choices are available to you:
Some developers are more comfortable with the first method. They think that the BLOB is more readily available if it's stored in the file system, instead of in the Oracle database. They reason that they gain very little by storing a BLOB in a table column if the Oracle database can't (or shouldn't) manipulate the BLOB.
However, other developers see an advantage in centralizing all data storage in the Oracle database. They argue that this approach provides greater portability; removing references to a directory and filename leaves fewer OS-specific issues to deal with.
A column defined as LONG RAW can accommodate up to 2GB for each row. Like LONG columns, LONG RAW columns have a number of limitations. For example, you cannot use any of the built-in functions with a LONG RAW column.
Page 52
Oracle also provides the RAW datatype, which can accommodate up to 255 bytes of binary data. Because of this storage restriction, a RAW column is less useful than a LONG RAW column.
As discussed in this lesson, try to follow these steps when designing a logical data model:
Keep the following concepts in mind when you work with Oracle datatypes:
On Day 4, you learn how to actually build the tables and other structures that implement a logical data model.
Q Won't performance be a problem if all of the tables of an application are in Third Normal Form?A It is a mistake to assume that the performance of a database application will always be substandard if its tables are in Third Normal Form. It's better to start out with a design in Third Normal Formor higherand then identify any areas where performance may be a problem.
Page 53
Q In an Oracle database, how many columns can a table contain?
A A table can contain up to 254 columns.
The purpose of the Workshop is to enable you to test your knowledge of the material discussed in the lesson. See if you can correctly answer the questions in the quiz and complete the exercises before you continue with tomorrow's lesson.