Chapt 23
Chapt 23
ery large databases are a rapidly growing trend in the enterprise world. From the gigabyte to the terabyte monsters, todays RDBMS must be able to store and manage very large databases. This chapter discusses how to architect and implement these monsters through the use of Oracle8 database Object partitioning and large Object types.
23
C H A P T E R
In This Chapter
Introduction to very large databases (VLDB) Table partitioning Index partitioning Large Object types (BLOB, NLOB, CLOB, and BFILE) The DBMS_LOB package
570
VLDBs can be categorized into two types: 3 Online Transaction Processing Databases (OLTP) 3 Data warehouses Online Transaction Processing Databases support a large concurrent User population. The database transactions usually follow the simple Create, Read, Update, and Delete (CRUD) matrix. Data warehouses, on the other hand, have an infrastructure that supports both OLTP and Decision Support Systems (DSS). The segregation of data within the data warehouse makes this type of database unique. A data warehouse is architected to store all enterprise data requirements historical or current. The element of time splits the OLTP and DSS portions of the database. Oracle8 has been robustly improved to embrace todays VLDBs. The following Oracle8 database areas have been enhanced to store, manage, and support VLDBs: 3 Database Object partitioning 3 Transaction queuing 3 Networking through Net8 3 Parallel Server 3 Enterprise Manager 3 Oracle8 datatypes 3 Backup and recovery This chapter primarily focuses on database Object partitioning and Oracle8 datatypes in the context of VLDBs. You can easily locate the other subject areas in their respective chapters in this book.
571
Partition A
Partition B
Partition C
Partition
Partition D
Partition E
572
Query performance
Because partitions can be created based on ranges of certain Columns, queries that may require a full Table scan can focus on a particular partition or a range of partitions. This focus drastically reduces the search time necessary to satisfy the data requirements of a SQL query.
Disk access
Partitions allow a flexible physical implementation of a database Object. Partitions can be created on separate Tablespaces, which you can, in turn, place on their own physical disk. Having a dedicated disk controller permits faster searches on partitions. Database design can specify the high hit rate database Objects have their own dedicated disks.
Partition transparency
In todays complex application development environment, the developer certainly does not want physical Constraints on data access. Partition implementation is transparent to end Users. Users or developers do not need to be aware of the physical implementation of the database Objects that capability is available for query and I/O optimization.
An Index-Organized Table stores data sorted on the Primary Key. Use the CREATE Table command with the PARTITION BY Range clause to create a partitioned Table. This clause specifies the Columns from which Key Values will range-partition the Table. Use as many as sixteen Columns to specify the partition base.
573
For example, the following CREATE Table statement creates a STUDENTS Table with five partitions. Each partitions description specifies a partition name and physical attributes for the partition.
CREATE Table STUDENTS ( STUDENT_ID INTEGER NOT Null, STUDENT_FIRST_NAME VARCHAR2(25) Null , STUDENT_LAST_NAME VARCHAR2(25) Null , STUDENT_DEPT_ID INTEGER Null , STUDENT_ADDRESS VARCHAR2(50) Null , STUDENT_CITY VARCHAR2(25) Null , STUDENT_STATE VARCHAR2(15) Null , STUDENT_ZIP VARCHAR2(10) Null , STUDENT_BL_STATUS CHAR Null, CONSTRAINT DEPT_ID_PK Primary Key(STUDENT_DEPT_ID) ) PARTITION BY Range (STUDENT_DEPT_ID) ( PARTITION DEPT_ID_1 ValueS LESS THAN (100) TABLESPACE OM1, PARTITION DEPT_ID_2 ValueS LESS THAN (250) TABLESPACE OM2, PARTITION DEPT_ID_3 ValueS LESS THAN (500) TABLESPACE OM3, PARTITION DEPT_ID_4 ValueS LESS THAN (750) TABLESPACE OM4, PARTITION DEPT_ID_5 ValueS LESS THAN (MAXVALUE) TABLESPACE OM5);
STUDENTS table
DEPT_ID_1
DEPT_ID_2
DEPT_ID_3
Rangepartitioning
DEPT_ID_4
DEPT_ID_5
574
Note
Each partition can have its own storage characteristics allowing Tables to span multiple Tablespaces. The STUDENTS Table is partitioned based on the STUDENTS_DEPT_ID Column values. Five partitions are created with the following names and range values:
DEPT_ID_1 Range 0 to 99 DEPT_ID_2 Range 100 to 249 DEPT_ID_3 Range 250 to 499 DEPT_ID_4 Range 500 to 749 DEPT_ID_5 Range 750 to MAXVALUE
The MAXVALUE keyword allocates any rows that do not fit into the other partition range criteria to the last partition. The MAXVALUE keyword is usually reserved for the very last partition. The STUDENTS Table can also be partitioned using the Oracle8 Schema Manager. The Oracle8 Schema Manager provides a visual interface to create, maintain, split, and drop the partitions of a Table. Figure 23-3 illustrates the STUDENTS Table partitions in the Oracle8 Schema Manager.
575
If the partitioning Column contains null Key values, Oracle8 sorts them greater than the other partition Key values, but less than the MAXVALUE. Thus, in partitioning a Table on Columns that contain null values, the last partitions bounds should specify the MAXVALUE keyword. Otherwise, Oracle8 will not be able to place the respective null rows in any of the defined partition ranges and an error will occur for that transaction.
576
If a row is inserted with the Keys (2500, 150), the row is inserted into the DEPT_ID_2 partition because Key (2500, x) is less than (3000, x) and greater than (1000, 100). Multicolumn partitions are best used when even distribution of rows need to occur through the defined partitions.
Partition names
You must identify every partition by a name. Each partitions name must be unique in respect to the other partitions defined for the same parent Table or Index. This unique naming scheme enables you to refer to the partitions directly in data manipulation, Import, Export, and maintenance operations. For example, the following SELECT statement only returns rows that exist in the
DEPT_ID_1 partition. SELECT STUDENT_FIRST_NAME, STUDENT_DEPT_ID FROM AMY.STUDENTS Partition (DEPT_ID_1); STUDENT_FIRST_NAME STUDENT_DEPT_ID ........................................ Amy 50 Sampson 25 Einstein 68 Cortney 99 Patrick 54 Chandi 10 6 Rows selected.
577
Equi-partitioning
The equi-partition of Tables involves creating the same number of partitions with the same number of Columns for two or more related Tables. This also applies to a Table and its respective Indexes. For example, if the STUDENTS Table is partitioned using STUDENT_ID, and STUDENT_DEPT_ID and its respective Index also use the same partition Columns, the two are equi-partitioned. The equi-partition of Tables has the following advantages: 3 Oracle8 improves the partitioned Tables execution plan in complex JOIN and SORT operations. 3 Media recovery time is reduced as dependent Tables or Indexes can be recovered to the same time.
Note
You can achieve Table and Index equi-partitioning using local Indexes.
Local Indexes
Local Indexes contain partition Keys that only map to rows stored in a single named partition. If a local Index is created for the STUDENTS Table, five Indexes are created one for each partition. Create a local Index on a partition by issuing the CREATE Index command using the local attribute. For example, the following CREATE Index statement creates a local Index called DEPT_IDX on the STUDENTS Table:
CREATE Index DEPT_IDX ON STUDENTS (STUDENT_DEPT_ID) LOCAL ( PARTITION DEPT_ID_1 TableSPACE OM1,
578
STUDENTS table
DEPT_ID_1
DEPT_ID_2
DEPT_ID_3
Rangepartitioning
DEPT_ID_4
DEPT_ID_5
Every local Index is equi-partitioned with respect to the underlying Table. Thus, the Index is created using the same partition Columns and range-partition Keys as the underlying partitioned Table. These creation elements ensure the Index has the same partition bounds as the Table. Local Indexes have the following advantages: 3 Only one local Index is affected if a single partition undergoes maintenance. 3 Partition independence is supported. 3 Only local Indexes can support individual partition Import and Export routines. 3 Oracle8 ensures better query access plans.
579
3 Incomplete recovery is simplified because the partition and the respective local Index can be recovered to the same time. 3 Local Indexes can be rebuilt individually. 3 Bitmap Indexes are supported only as local Indexes. There are two types of local Indexes: 3 Local prefixed Indexes 3 Local nonprefixed Indexes
Global Indexes
A global Index contains Keys that refer to more than one partition of an underlying Table. A global Index is created by using the global attribute of the CREATE Index command. In general, all nonpartitioned Indexes are treated as global prefixed Indexes. For example, the DEPT_IDX Index on the STUDENTS Table can be created as a global Index with the following CREATE Index statement:
CREATE Index DEPT_IDX ON STUDENTS (STUDENT_DEPT_ID) GLOBAL Partition BY Range (STUDENT_DEPT_ID) (PARTITION DEPT_ID_1 ValueS LESS THAN (1000, 100) TABLESPACE OM1, PARTITION DEPT_ID_2 ValueS LESS THAN (2000, 250) TABLESPACE OM2, PARTITION DEPT_ID_3 ValueS LESS THAN (3000, 500) TABLESPACE OM3, PARTITION DEPT_ID_4 ValueS LESS THAN (4000, 750) TABLESPACE OM4, PARTITION DEPT_ID_5 ValueS LESS THAN (MAXVALUE,MAXVALUE) TABLESPACE OM5);
580
STUDENTS table
DEPT_ID_1
DEPT_ID_2
DEPT_ID_3
Rangepartitioning
DEPT_ID_4
DEPT_ID_5
Global index
Global partitions can be created with different partition bounds than the underlying Tables partitions. But even if you define the bounds identically to the underlying Table, Oracle8 does not treat global Indexes as equi-partition Indexes. As a result, global Indexes require more maintenance than local Indexes.
Note
When using Global Indexes, use the MAXVALUE keyword for the highest bound on the last partition. This keyword takes all respective values into account in the underlying Table. Maintaining global Indexes on a very large Table is time consuming because of the following reasons: 3 If the underlying partition is removed or moved, the global Index is immediately affected because it spans all partitions of the underlying Table. You need to rebuild the global Index with the time proportional to the size of the Table not the partition directly affected by the operation. 3 If the partition needs to be recovered to a time, the partition and the global Index need to be resynchronized to the same time. Thus, the global Index will need to be rebuilt.
581
ALTER Table
MODIFY partition RENAME partition MOVE partition ADD partition
Modifies the real physical attributes of the partition. Renames a partition to another name. Moves a partition to another segment. Adds a new partition to the Table. It is usually added after the highest partition. Removes a partition and its data from the Table. Efficiently removes all rows in a partition. Creates a new partition from an old partition. Converts a partitioned Table into a nonpartitioned Table and also converts a nonpartitioned Table into a partitioned Table (the conversion includes Indexes).
582
ALTER Index
REBUILD partition DROP partition SPLIT partition UNUSABLE RENAME partition
Rebuilds one partition of an Index. Removes a partition from a global Index. Splits a global partition into two partitions. Marks the Index as unusable. Renames a partitioned Index.
583
Oracle8 introduces the new Large Object Column types, or LOBs. You can use LOBs to store up to 4GB of data internally. Oracle8 also provides better storage and piece-wise access mechanisms than Oracle7xx.
LOB datatypes
The two categories of LOB are differentiated by whether the datatype is stored internally or externally in respect to the Oracle8 database. Unless otherwise specified, only the locators for these LOBs are stored in their respective Table Columns.
Note
Locators point to where the actual LOB data is actually stored in the database or on the operating system disks.
Internal LOBs
The following internal LOBs types in Tables store up to 4GB of data: 3 BLOB (Unstructured binary data) 3 CLOB (Single-byte character data) 3 NCLOB (Fixed-length multibyte national character data)
External LOBs
The BFILE is the only external LOB type supported by Oracle8. This LOB type externally stores data to the database as an operating system file. Unlike the internal LOBs, the BFILE type is read-only. Oracle8 also provides no transaction control or integrity checks on BFILE types. BFILEs can also store up to 4GB of data.
584
) STORAGE (INITIAL 10K NEXT 10K PCTINCREASE 30) LOB (STUDENT_PICTURE) STORE AS (TABLESPACE STUDENT_PIC_ts STORAGE (INITIAL 100M NEXT 100M PCTINCREASE 50)), LOB (STUDENT_HISTORY) STORE AS (TABLESPACE STUDENT_HIST_ts Storage (INITIAL 200K NEXT 100K PCTINCREASE 50));
Oracle8 database
STUDENT_PIC tablespace
STUDENT_HIST tablespace
STUDENT table
Operating system file system Figure 23-6: The LOB storage in the STUDENT Table
The STUDENT Table contains the following LOB Columns: 3 STUDENT_PICTURE (BLOB) 3 STUDENT_HISTORY (CLOB) 3 STUDENT_REPORT (BFILE) Each LOB except the BFILE is assigned a separate Tablespace with its own storage parameters. These parameters are specified by the following statement:
LOB (STUDENT_PICTURE) STORE AS
585
(TABLESPACE STUDENT_PIC_ts STORAGE (INITIAL 10M NEXT 10M PCTINCREASE 50)), LOB (STUDENT_HISTORY) STORE AS (TABLESPACE STUDENT_HIST_ts STORAGE (INITIAL 200K NEXT 100K PCTINCREASE 50))
The EMPTY_BLOB() and EMPTY_CLOB() functions in the Column definitions initialize the respective internal LOBs to zero length and provide a default locator value.
STUDENT_PICTURE STUDENT_HISTORY
Note
BLOB CLOB
EMPTY_BLOB(), EMPTY_CLOB(),
As this book goes to press, Tables that contain LOBs can only be created using SQL. The Oracle8 Schema Manager does not support LOBs as Column types when creating a Table.
LOB locators
A LOB Column must contain a LOB locator value before a value can be updated or inserted for that LOB. A locator acts as a pointer to where the LOB is actually stored. This includes Internal and External LOB Types. In other words, the LOB Column must not be null for use in an UPDATE or INSERT statement.
Contention is reduced on a Tablespace if the data and the LOBs are separated into different Tablespaces. You can use the following storage options when creating LOBs: 3 PCTVERSION 3 CACHE 3 NOCACHE 3 LOGGING 3 NOLOGGING
586
PCTVERSION
The PCTVERSION option determines the percentage of used LOB data pages permitted before reuse. In general, if the LOB will be consistently read-only, the PCTVERSION should be set to five percent or lower. If the LOB is going to experiences-consistent-read and update operations, the
PCTVERSION should be set to approximately thirty percent.
CACHE / NOCACHE
These options specify whether to cache the LOB values in memory after use. Caching the LOB increases the access speed to locate and manipulate the LOB. Be sure to specify the CACHE option if you plan to access the LOB frequently; otherwise, use NOCACHE.
LOGGING/NOLOGGING
The LOGGING option generates a record of all operations on the LOB into the online redo log files. The NOLOGGING option does not record any LOB operations in the online redo log files. Consider this option if the LOB contains critical data. Media recovery cannot occur if the LOB is set to NOLOGGING.
CHUNK
The CHUNK option specifies the number of LOB data blocks read at one time. For example, if you specify CHUNK 8, and the data block size is 2K, a 16K page will be read each time LOB is accessed.
Note
The INITIAL and NEXT parameters must always be larger than the CHUNK value.
587
An empty value in LOB contains a locator and has zero length. The following example initializes the STUDENT Tables LOBs to null:
INSERT INTO STUDENT (STUDENT_ID, STUDENT_FIRST_NAME, STUDENT_LAST_NAME, STUDENT_PICTURE, STUDENT_DEPT_ID, STUDENT_ADDRESS , STUDENT_CITY, STUDENT_STATE, STUDENT_ZIP, STUDENT_HISTORY, STUDENT_REPORT) VALUES (1003, AMY,CHANDI, Null, 1, 55 Sutton Place #922, Austin, TX, 78587, NULL, Null);
The STUDENT_PICTURE, STUDENT_HISTORY, and STUDENT_REPORT LOBs are all set to null. The following example initializes the respective LOBs in the STUDENT Table to empty:
INSERT INTO STUDENT (STUDENT_ID, STUDENT_FIRST_NAME, STUDENT_LAST_NAME, STUDENT_PICTURE, STUDENT_DEPT_ID, STUDENT_ADDRESS , STUDENT_CITY, STUDENT_STATE, STUDENT_ZIP, STUDENT_HISTORY, STUDENT_REPORT) VALUES (1003, AMY,CHANDI, EMPTY_BLOB(), 1, 55 Sutton Place #922, Austin, TX, 78587, EMPTY_CLOB(), Null);
The EMPTY_BLOB() function initializes BLOB datatypes. The EMPTY_CLOB() function initializes NLOB and CLOB datatypes.
Using BFILEs
BFILEs, as stated before, are externally stored LOBs. Typically, a BFILE is a file
stored in the operating system file system, CD-ROM, or any other external media devices connected to the Oracle8 server. This also includes network drives.
588
Before you can use BFILEs within a Table, a DIRECTORY Object needs to be created. The DIRECTORY Object is used as an alias to the physical operating system directory that will contain the BFILE Object. Use the Create DIRECTORY command to create DIRECTORY Objects. For example, the following statement associates an alias AMY_ALIAS with the path D:\ORANT\AMY_FILES:
CREATE DIRECTORY AMY_ALIAS AS D:\ORANT\AMY_FILES;
The Oracle8 DBA must execute the preceding two commands regarding the DIRECTORY Object. Use the BFILENAME function to insert a value into the Tables BFILE Columns. This function maps the BFILE Column to the physical file. For example, the following statement inserts the file AMY_REPORT.DOC into the STUDENT Table:
INSERT INTO STUDENT (STUDENT_ID, STUDENT_FIRST_NAME, STUDENT_LAST_NAME, STUDENT_PICTURE, STUDENT_DEPT_ID, STUDENT_ADDRESS , STUDENT_CITY, STUDENT_STATE, STUDENT_ZIP, STUDENT_HISTORY, STUDENT_REPORT) VALUES (1003, AMY,CHANDI, EMPTY_BLOB(), 1, 55 Sutton Place #922, Austin, TX, 78587, EMPTY_CLOB(), BFILENAME(AMY_ALIAS, AMY_REPORT.DOC);
Note
Close all open BFILEs after their usage by using the DBMS_LOB.FILECLOSE call. Constraints exist on the maximum number of BFILEs open at any given time. This Constraint is set in the Session_MAX_OPEN_FILES parameter in the INIT.ORA file. The default value for this parameter is ten.
Manipulating LOBs
The three following methods access LOBs in a Table: 3 Using the Oracle8 API 3 Using the DBMS_LOB Package 3 Using the Oracle Call Interface (OCI) The remaining part of this chapter focuses on manipulating LOBs using the DBMS_LOB Package.
589
Reading LOBs
The DBMS_LOB.READ function in the DBMS_LOB Package is best used for all LOB read operations. For example, the following code reads the STUDENT_HISTORY from the STUDENT Table for a student with an id of 1056:
DECLARE STU_HISTORY CLOB; HISTORY_LEN BINARY_INTEGER:= 2000; OFFSET INTEGER:= 1; BUFFER_VAR RAW(2000); BEGIN SELECT STUDENT_HISTORY INTO STU_HISTORY FROM STUDENT WHERE id = 1056; DBMS_LOB.READ(STU_HISTORY, HistorY_LEN, OFFSET, Buffer_VAR); END;
Updating a LOB
LOBs can also be updated using subqueries. The following example updates a students picture from another row in the same Table. The LOB locator is copied into the row with the LOB value stored out-of-line.
590
UPDATE STUDENT SET STUDENT_PICTURE = (SELECT STUDENT_PICTURE FROM STUDENT WHERE STUDENT_ID = 7266); WHERE id = 1056;
Note
Lock a LOBs row before updating the LOB using the SQL SELECT FOR update statement.
If the LOB is a BFILE type, the physical file is not deleted by the DELETE operation. The physical file must be manually deleted from the operating system.
Appends the contents of the source LOB to a destination LOB. Copies all or part of the source LOB to a destination LOB. Erases all or part of a LOB. Loads a BFILEs data into an internal LOB. Trims a LOB value to the specified shorter length. Writes data to a LOB from a specified offset position.
Retrieves the length of the LOB. Returns the matching position of the nth occurrence of a specified pattern in the LOB.
591
READ() SUBSTR()
Reads data from the LOB starting at a specified offset position. Returns part of the LOB value starting at a specified offset position. Compares two similar LOB types.
COMPARE()
Closes the BFILE. Closes all previously opened BFILEs. Verifies if a specific BFILE exists on the operating system file system. Retrieves the directory alias and file name for a BFILE. Verifies if a BFILE is open. Opens a BFILE.
DBMS_LOB exceptions
DBMS_LOB Package raises exceptions that can be trapped using the exception
keyword in a PL/SQL block. The following exceptions can be raised by the DBMS_LOB package:
INVALID_ARGVAL
Occurs if the DBMS_LOB routine arguments are either null or out of range. Occurs if a read or write operation by a DBMS_LOB routine exceeds the LOB size bounds. Occurs if no data is found in the LOB. Occurs if the DBMS_LOB routine accepts an invalid input argument.
ACCESS_ERROR
NO_DATA_FOUND VALUE_ERROR
APPEND()
This routine appends the source LOB to the destination LOB and takes the following arguments:
592
dest_lob src_lob
Identifies the LOB to be appended. Identifies the LOB to be read and appended to dest_lob.
The dest_lob row must be locked using the SELECT FOR update statement.
COMPARE()
This routine compares two LOBs of the same datatype. This routine returns zero if the two LOBs match exactly; otherwise, a non-zero integer is returned. This routine takes the following arguments:
lob_1 lob_2 num_bytes offset_1 offset_2
Locator of the first LOB to compare. Locator of the second LOB to compare. Number of bytes to compare from lob_1 and lob_2. Offset of lob_1. Offset of lob_2.
If a BFILE LOB is being compared, the BFILE must be successfully opened using the DBMS_LOB.FILEOPEN() routine. Afterwards, the BFILE must be closed using the DBMS_LOB.FILECLOSE() routine.
COPY()
This routine copies all or part of a source LOB to a destination LOB and takes the following arguments:
dest_lob src_lob num_bytes dest_offset src_offset
Locator of the destination LOB. Locator of the source LOB to be copied to the dest_lob. Number of bytes to copy. Specifies the offset of where to copy into the dest_lob. Specifies the offset of the source LOB from which to initiate copying.
593
The dest_lob row is locked using the SELECT FOR update statement.
ERASE()
This routine erases all or part of a LOB. The routine returns the number of bytes erased as a return value and takes the following arguments:
lob_1 num_bytes lob_offset
Locator of the LOB to be erased. Number of bytes to erase. Specifies the offset of LOB to be erased.
LoadFROMFILE()
This routine copies all or part of an external LOB to an internal LOB and takes the following arguments:
dest_lob src_lob
Locator of the destination LOB. Locator of the external source LOB (BFILE) to be loaded to the dest_lob. Number of bytes to copy from the BFILE. Specifies the offset of where to copy into the dest_lob. Specifies the offset of the source LOB from which to initiate loading.
A BFILE LOB must be successfully opened using the DBMS_LOB.FILEOPEN() routine. Afterwards, you must close the BFILE using the DBMS_LOB.FILECLOSE() routine.
594
TRIM()
This routine trims the value of the internal LOB to a specified length and takes the following arguments:
lob_trim num_bytes
Locator of the LOB to be trimmed. Number of bytes to trim from the LOB.
WRITE()
This routine writes an amount of data into a LOB from the offset position to a specified length. Any data already contained in that space is overwritten. The data must be written from a buffer variable that can be defined in a PL/SQL block. This routine takes the following arguments:
lob_write num_bytes Offset buffer
Locator of the LOB to be written. Number of bytes to write into the LOB. Specifies the offset of where to start the write operation. Specifies the input buffer for the write operation.
GETLENGTH()
This routine returns the length of a LOB and takes the following arguments:
lob_1
Locator of a LOB.
INSTR()
This routine searches a LOB for a specified pattern of data. The return value identifies the starting position of the pattern. This routine takes the following arguments:
Chapter 23 3 Heading 1
595
Locator of the LOB to be matched with a pattern. Specifies the pattern that needs to be located in lob_1. Specifies the offset of where to start the pattern matching operation. Specifies the occurrence number to find.
occurrence_no
The pattern and the LOB value must be from the same character set.
READ()
This routine reads a specified amount of LOB into a buffer. You can then use the buffer to perform write operations into other LOB records. This routine returns the number of bytes read and takes the following arguments:
lob_1 num_bytes offset buffer
Locator of the LOB to read. Number of bytes to read from lob_1. Specifies the offset of where to start the read operation. Specifies the buffer to store the output of the read operation.
SUBSTR()
This routine extracts a specified amount of data from a LOB and returns it to the calling application. This routine takes the following arguments:
lob_1 num_bytes offset
Locator of the LOB from which to extract data. Number of bytes to extract from lob_1. Specifies the offset of where to start the extract operation.
596
FileCLOSE()
This routine closes a successfully opened external LOB (BFILE) file and takes the following arguments:
bfile_lob
FileCLOSEALL()
This routine closes all open BFILEs in a specific session. The syntax for the FileCLOSEALL() routine follows:
DBMS_LOB.FILECLOSEALL;
Note
FileEXISTS()
This routine verifies a BFILE locator actually points to a valid file on the operating systems file system. This routine takes the following arguments:
bfile_lob
FileGETNAME()
This routine returns the directory alias and physical file name of a specific BFILE locator. This routine cannot validate if the physical file exists and takes the following arguments:
bfile_lob dir_alias file_name
Locator of the BFILE LOB. Variable to hold the alias directory. Variable to hold the physical file name.
Chapter 23 3 Heading 1
597
FileISOPEN()
This routine verifies whether a specific BFILE is open and takes the following arguments:
bfile_lob
FileOPEN()
This Routine opens a BFILE for read-only access. No other operations are permitted on the BFILE because it is stored externally in respect to the Oracle8 database. This Routine takes the following arguments:
bfile_lob open_mode
Locator of the BFILE LOB. Specifies the mode to open the BFILE.
Currently, the open_mode can only be set to DBMS_LOB.FILE_READONLY. Oracle may extend the BFILE manipulation capabilities at a later time.
Summary
With the lowering of hardware prices and the escalation of data use data, ithat the database has become the central repository for all data in an enterprise. As a result, the database must store more complex and large data, such as video, movies, graphic images, and sound (wav) files. In Addition, the storage requirements of and more data in a typical enterprise has grown exponentially. The term VLDB refers to databases and a terabyte in size. This chapter has addressed the design, implementation, and management of VLDBs through the use of Object Partitioning and Large Objects (LOBs). The following key points can summarize this chapter: 3 Commonly, certain database implementations only contain a few extremely large tables which qualify the database as VLDB. These objects can be partitioned into smaller and more manageable units. 3 Partitioned units are transparent to Users.
598
3 The PARTITION BY RANGE clause used within a CREATE TABLE statement creates a partitioned table. 3 The PARTITION BY RANGE clause permits the horizontal partitioning of data in a custom or equi-partitioned fashion. 3 The following Indexes can be created for partitioned tables: local prefixed, local non prefixed, and global. 3 Partitioning a very large Table has the following advantages: reduction of database downtime, increased query performance, and better disk access. 3 LOB datatypes can be stored internally or externally with respect to the database. 3 BLOBs, CLOBs, and NCLOBs datatypes can all be stored within a 4GB table. After that point they are stored externally in respect to the Table and only referenced from within the Table. 3 BFILE datatypes are stored externally as an operating system file. 3 The DBMS_LOB package can be used to manipulate LOB datatype Columns in a Table.